LFS 11.2(Linux From Scratch)构建过程全记录(四):最后的准备
写在前面
本章将进行一系列的环境配置
目录创建
在LFS中创建文件目录
我们可以用以下的指令来创建一些基础的目录,并进行连接
mkdir -pv $LFS/{etc,var} $LFS/usr/{bin,lib,sbin} for i in bin lib sbin; do ln -sv usr/$i $LFS/$i done case $(uname -m) in x86_64) mkdir -pv $LFS/lib64 ;; esac mkdir -pv $LFS/tools
执行该代码后,我们成功创建了一系列的目录,执行结果如下:
用户组操作
我们需要添加一个普通用户组到用户中,以免特权指令影响到新操作系统的安全
其代码如下:
groupadd lfs useradd -s /bin/bash -g lfs -m -k /dev/null lfs
我们需要给lfs账户一个密码,指令如下:
passwd lfs
输入后我们需要键入密码并重复键入密码
我们要授予lfs对$ lfs下所有目录的完全访问权:
chown -v lfs $LFS/{usr{,/*},lib,var,etc,bin,sbin,tools} case $(uname -m) in x86_64) chown -v lfs $LFS/lib64 ;; esac
该指令的输出如下:
root@ubuntu:/home/alphainf# chown -v lfs $LFS/{usr{,/*},lib,var,etc,bin,sbin,tools} changed ownership of '/mnt/lfs/usr' from root to lfs changed ownership of '/mnt/lfs/usr/bin' from root to lfs changed ownership of '/mnt/lfs/usr/lib' from root to lfs changed ownership of '/mnt/lfs/usr/sbin' from root to lfs ownership of '/mnt/lfs/lib' retained as lfs changed ownership of '/mnt/lfs/var' from root to lfs changed ownership of '/mnt/lfs/etc' from root to lfs ownership of '/mnt/lfs/bin' retained as lfs ownership of '/mnt/lfs/sbin' retained as lfs changed ownership of '/mnt/lfs/tools' from root to lfs root@ubuntu:/home/alphainf# case $(uname -m) in > x86_64) chown -v lfs $LFS/lib64 ;; > esac changed ownership of '/mnt/lfs/lib64' from root to lfs
接下来,我们切换账户到lfs下进行登陆,切换的指令为:
su - lfs
运行结果如下:
我们成功地切换到了lfs账户
新账户环境设置
设置.bash_profile,指令如下:
cat > ~/.bash_profile << "EOF" exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash EOF
设置.bashrc文件,指令如下:
cat > ~/.bashrc << "EOF" set +h umask 022 LFS=/mnt/lfs LC_ALL=POSIX LFS_TGT=$(uname -m)-lfs-linux-gnu PATH=/usr/bin if [ ! -L /bin ]; then PATH=/bin:$PATH; fi PATH=$LFS/tools/bin:$PATH CONFIG_SITE=$LFS/usr/share/config.site export LFS LC_ALL LFS_TGT PATH CONFIG_SITE EOF
设置完毕后,运行以下指令:
source ~/.bash_profile
设置完毕后,我们保存快照