目录
  1. 1. BLFS构建02-LFS配置之后的问题
    1. 1.1. 终端字体
    2. 1.2. 关于固件
    3. 1.3. 关于设备
    4. 1.4. 增加用户的配置
      1. 1.4.1. skel文件(框架目录)
    5. 1.5. bash启动文件
    6. 1.6. vim的配置文件
    7. 1.7. 自定义登录提示语
    8. 1.8. 随机数生成器
    9. 1.9. lsb_release-1.4
BLFS构建02-LFS配置之后的问题

BLFS构建02-LFS配置之后的问题

终端字体

  • 如果你没有安装字体
1
setfont /path/to/yourfont.ext
  • 如果已经有了字体
1
setfont /path/to/yourfont.ext
  • 测试字体
1
showconsolefont

关于固件

关于设备

  • 多声卡设置
1
2
3
4
5
6
# /boot/grub/grub.cfg
snd-fm801.index=0 snd-ens1371.index=1

# /etc/modprobe.conf
options snd-fm801 index=0
options snd-ens1371 index=1
  • usb设备
1
2
# /etc/fstab
usbfs /proc/bus/usb usbfs devgid=14,devmode=0660 0 0

增加用户的配置

skel文件(框架目录)
+ 简介
  skel是skeleton的缩写意为骨骼、框架。
+ 作用
  用于初始化新用户的根目录,系统将此目录下的文件都复制到新建用户的目录下,并且将用户属主与用户组调整为与新建用户根目录相同

bash启动文件

  • /etc/profile文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Begin /etc/profile
# Written for Beyond Linux From Scratch
# by James Robertson <jameswrobertson@earthlink.net>
# modifications by Dagmar d'Surreal <rivyqntzne@pbzpnfg.arg>

# System wide environment variables and startup programs.

# System wide aliases and functions should go in /etc/bashrc. Personal
# environment variables and startup programs should go into
# ~/.bash_profile. Personal aliases and functions should go into
# ~/.bashrc.

# Functions to help us manage paths. Second argument is the name of the
# path variable to be modified (default: PATH)
pathremove () {
local IFS=':'
local NEWPATH
local DIR
local PATHVARIABLE=${2:-PATH}
for DIR in ${!PATHVARIABLE} ; do
if [ "$DIR" != "$1" ] ; then
NEWPATH=${NEWPATH:+$NEWPATH:}$DIR
fi
done
export $PATHVARIABLE="$NEWPATH"
}

pathprepend () {
pathremove $1 $2
local PATHVARIABLE=${2:-PATH}
export $PATHVARIABLE="$1${!PATHVARIABLE:+:${!PATHVARIABLE}}"
}

pathappend () {
pathremove $1 $2
local PATHVARIABLE=${2:-PATH}
export $PATHVARIABLE="${!PATHVARIABLE:+${!PATHVARIABLE}:}$1"
}

export -f pathremove pathprepend pathappend

# Set the initial path
export PATH=/bin:/usr/bin

if [ $EUID -eq 0 ] ; then
pathappend /sbin:/usr/sbin
unset HISTFILE
fi

# Setup some environment variables.
export HISTSIZE=1000
export HISTIGNORE="&:[bf]g:exit"

# Set some defaults for graphical systems
export XDG_DATA_DIRS=${XDG_DATA_DIRS:-/usr/share/}a
export XDG_CONFIG_DIRS=${XDG_CONFIG_DIRS:-/etc/xdg/}
export XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR:-/tmp/xdg-$USER}

# Setup a red prompt for root and a green one for users.
NORMAL="\[\e[0m\]"
RED="\[\e[1;31m\]"
GREEN="\[\e[1;32m\]"
if [[ $EUID == 0 ]] ; then
PS1="$RED\u [ $NORMAL\w$RED ]# $NORMAL"
else
PS1="$GREEN\u [ $NORMAL\w$GREEN ]\$ $NORMAL"
fi

for script in /etc/profile.d/*.sh ; do
if [ -r $script ] ; then
. $script
fi
done

unset script RED GREEN NORMAL

# End /etc/profile
  • 创建profile.d目录(存放bash配置文件)
1
install --directory --mode=0755 --owner=root --group=root /etc/profile.d
  • 创建/etc/profile.d/bash_completion.sh脚本(用于bash补全)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
cat > /etc/profile.d/bash_completion.sh << "EOF"
# Begin /etc/profile.d/bash_completion.sh
# Import bash completion scripts

# If the bash-completion package is installed, use its configuration instead
if [ -f /usr/share/bash-completion/bash_completion ]; then

# Check for interactive bash and that we haven't already been sourced.
if [ -n "${BASH_VERSION-}" -a -n "${PS1-}" -a -z "${BASH_COMPLETION_VERSINFO-}" ]; then

# Check for recent enough version of bash.
if [ ${BASH_VERSINFO[0]} -gt 4 ] || \
[ ${BASH_VERSINFO[0]} -eq 4 -a ${BASH_VERSINFO[1]} -ge 1 ]; then
[ -r "${XDG_CONFIG_HOME:-$HOME/.config}/bash_completion" ] && \
. "${XDG_CONFIG_HOME:-$HOME/.config}/bash_completion"
if shopt -q progcomp && [ -r /usr/share/bash-completion/bash_completion ]; then
# Source completion code.
. /usr/share/bash-completion/bash_completion
fi
fi
fi

else

# bash-completions are not installed, use only bash completion directory
if shopt -q progcomp; then
for script in /etc/bash_completion.d/* ; do
if [ -r $script ] ; then
. $script
fi
done
fi
fi

# End /etc/profile.d/bash_completion.sh
EOF

+_创建/etc/bash_completion.d目录(bash补全的详细配置)

1
install --directory --mode=0755 --owner=root --group=root /etc/bash_completion.d
  • /etc/profile.d/dircolors.sh(目录颜色配置)
1
2
3
4
5
6
7
8
9
10
11
12
13
cat > /etc/profile.d/dircolors.sh << "EOF"
# Setup for /bin/ls and /bin/grep to support color, the alias is in /etc/bashrc.
if [ -f "/etc/dircolors" ] ; then
eval $(dircolors -b /etc/dircolors)
fi

if [ -f "$HOME/.dircolors" ] ; then
eval $(dircolors -b $HOME/.dircolors)
fi

alias ls='ls --color=auto'
alias grep='grep --color=auto'
EOF
  • /etc/profile.d/extrapaths.sh(增加有用的路径到PATH中)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
cat > /etc/profile.d/extrapaths.sh << "EOF"
if [ -d /usr/local/lib/pkgconfig ] ; then
pathappend /usr/local/lib/pkgconfig PKG_CONFIG_PATH
fi
if [ -d /usr/local/bin ]; then
pathprepend /usr/local/bin
fi
if [ -d /usr/local/sbin -a $EUID -eq 0 ]; then
pathprepend /usr/local/sbin
fi

# Set some defaults before other applications add to these paths.
pathappend /usr/share/man MANPATH
pathappend /usr/share/info INFOPATH
EOF
  • /etc/profile.d/readline.sh(设置默认的.inputrc配置文件)
1
2
3
4
5
6
7
cat > /etc/profile.d/readline.sh << "EOF"
# Setup the INPUTRC environment variable.
if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ] ; then
INPUTRC=/etc/inputrc
fi
export INPUTRC
EOF
  • /etc/profile.d/umask.sh(设置umask)
1
2
3
4
5
6
7
8
cat > /etc/profile.d/umask.sh << "EOF"
# By default, the umask should be set.
if [ "$(id -gn)" = "$(id -un)" -a $EUID -gt 99 ] ; then
umask 002
else
umask 022
fi
EOF
  • /etc/profile.d/i18n.sh(设置语言支持)
1
2
3
4
cat > /etc/profile.d/i18n.sh << "EOF"
# Set up i18n variables
export LANG=zh_CN.UTF-8
EOF
  • /etc/bashrc(bash的配置文件)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
cat > /etc/bashrc << "EOF"
# Begin /etc/bashrc
# Written for Beyond Linux From Scratch
# by James Robertson <jameswrobertson@earthlink.net>
# updated by Bruce Dubbs <bdubbs@linuxfromscratch.org>

# System wide aliases and functions.

# System wide environment variables and startup programs should go into
# /etc/profile. Personal environment variables and startup programs
# should go into ~/.bash_profile. Personal aliases and functions should
# go into ~/.bashrc

# Provides colored /bin/ls and /bin/grep commands. Used in conjunction
# with code in /etc/profile.

alias ls='ls --color=auto'
alias grep='grep --color=auto'

# Provides prompt for non-login shells, specifically shells started
# in the X environment. [Review the LFS archive thread titled
# PS1 Environment Variable for a great case study behind this script
# addendum.]

NORMAL="\[\e[0m\]"
RED="\[\e[1;31m\]"
GREEN="\[\e[1;32m\]"
if [[ $EUID == 0 ]] ; then
PS1="$RED\u [ $NORMAL\w$RED ]# $NORMAL"
else
PS1="$GREEN\u [ $NORMAL\w$GREEN ]\$ $NORMAL"
fi

unset RED GREEN NORMAL

# End /etc/bashrc
EOF
  • ~/.bash_profile()
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
cat > ~/.bash_profile << "EOF"
# Begin ~/.bash_profile
# Written for Beyond Linux From Scratch
# by James Robertson <jameswrobertson@earthlink.net>
# updated by Bruce Dubbs <bdubbs@linuxfromscratch.org>

# Personal environment variables and startup programs.

# Personal aliases and functions should go in ~/.bashrc. System wide
# environment variables and startup programs are in /etc/profile.
# System wide aliases and functions are in /etc/bashrc.

if [ -f "$HOME/.bashrc" ] ; then
source $HOME/.bashrc
fi

if [ -d "$HOME/bin" ] ; then
pathprepend $HOME/bin
fi

# Having . in the PATH is dangerous
#if [ $EUID -gt 99 ]; then
# pathappend .
#fi

# End ~/.bash_profile
EOF


#将配置复制到skel目录中,使其能在创建新用户时默认生成到新用户主目录中
cp ~/.bash_profile /etc/skel
  • ~/.profile(私有环境变量配置文件,只在登入的时候执行一次)
1
2
3
4
5
6
7
8
9
10
11
12
13
cat > ~/.profile << "EOF"
# Begin ~/.profile
# Personal environment variables and startup programs.

if [ -d "$HOME/bin" ] ; then
pathprepend $HOME/bin
fi

# Set up user specific i18n variables
#export LANG=<ll>_<CC>.<charmap><@modifiers>

# End ~/.profile
EOF
  • ~/.bashrc(用户专用bash配置文件)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
cat > ~/.bashrc << "EOF"
# Begin ~/.bashrc
# Written for Beyond Linux From Scratch
# by James Robertson <jameswrobertson@earthlink.net>

# Personal aliases and functions.

# Personal environment variables and startup programs should go in
# ~/.bash_profile. System wide environment variables and startup
# programs are in /etc/profile. System wide aliases and functions are
# in /etc/bashrc.

if [ -f "/etc/bashrc" ] ; then
source /etc/bashrc
fi

# Set up user specific i18n variables
#export LANG=<ll>_<CC>.<charmap><@modifiers>

# End ~/.bashrc
EOF
  • ~/.bash_logout(bash注销)
1
2
3
4
5
6
7
8
9
cat > ~/.bash_logout << "EOF"
# Begin ~/.bash_logout
# Written for Beyond Linux From Scratch
# by James Robertson <jameswrobertson@earthlink.net>

# Personal items to perform on logout.

# End ~/.bash_logout
EOF
  • /etc/dircolors(设置ls指令显示目录或文件时用的色彩)
1
dircolors -p > /etc/dircolors

vim的配置文件

  • .vimrc
1
2
3
4
5
6
7
8
cat > /etc/skel/.vimrc << "EOF"
" Begin .vimrc

set columns=80
set wrapmargin=8
set ruler

" End .vimrc

自定义登录提示语

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
cat > /etc/issue << "EOF"
b Insert the baudrate of the current line.
d Insert the current date.
s Insert the system name, the name of the operating system.
l Insert the name of the current tty line.
m Insert the architecture identifier of the machine, e.g., i686.
n Insert the nodename of the machine, also known as the hostname.
o Insert the domainname of the machine.
r Insert the release number of the kernel, e.g., 2.6.11.12.
t Insert the current time.
u Insert the number of current users logged in.
U Insert the string "1 user" or "<n> users" where <n> is the
number of current users logged in.
v Insert the version of the OS, e.g., the build-date etc.
EOF

随机数生成器

1
2
3
#将脚本复制到系统启动脚本中
cp -r blfs-bootscripts-20180105/blfs/init.d/random /etc/rc.d/init.d/
make install-random #进行安装

lsb_release-1.4

  • 介绍
    这个脚本显示的是linux发行版的标准基础状态信息
  • 下载安装
1
2
3
4
5
6
7
wget https://downloads.sourceforge.net/lsb/lsb-release-1.4.tar.gz
tar -zxvf lsb-release-1.4.tar.gz
cd lsb-release-1.4
sed -i "s|n/a|unavailable|" lsb_release
./help2man -N --include ./lsb_release.examples --alt_version_key=program_version ./lsb_release > lsb_release.1
install -v -m 644 lsb_release.1 /usr/share/man/man1
install -v -m 755 lsb_release /usr/bin
文章作者: rack-leen
文章链接: http://yoursite.com/2019/06/11/BLFS/BLFS%E6%9E%84%E5%BB%BA02-LFS%E9%85%8D%E7%BD%AE%E4%B9%8B%E5%90%8E%E7%9A%84%E9%97%AE%E9%A2%98/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 rack-leen's blog
打赏
  • 微信
  • 支付宝

评论