- 增加root登录密码
进入make menuconfig—>System configuration —>Root password 键入自己的密码
(1234) Root password
- 编译后,烧录sdcard.img。启动
Welcome to Buildroot
buildroot login: root
Password:
#
#
#
# cd /
# ls
bin lib lost+found opt run tmp
dev lib32 media proc sbin usr
etc linuxrc mnt root sys var
#
#
- 以上文件系统已经顺利启动,但是shell提示符仅有一个“#”。具体原因系统变量PS1并未设置,采用的是默认值!
具体设置查看/etc/profile
# cd /etc
# ls
fstab hosts issue os-release profile.d services
group init.d mtab passwd protocols shadow
hostname inittab network profile resolv.conf shells
# vi profile
export PATH="/bin:/sbin:/usr/bin:/usr/sbin"
if [ "$PS1" ]; then
if [ "`id -u`" -eq 0 ]; then
export PS1='# '
else
export PS1='$ '
fi
fi
export EDITOR='/bin/vi'
# Source configuration files from /etc/profile.d
for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
. $i
fi
done
unset i
- 修改PS1
直接键入export PS1="[\e[1;36m][\u@\h \W]\$[\e[0m]"
# export PS1="\[\e[1;36m\][\u@\h \W]\\$\[\e[0m\]"
[root@buildroot etc]#
[root@buildroot etc]#ls
fstab hosts issue os-release profile.d services
group init.d mtab passwd protocols shadow
hostname inittab network profile resolv.conf shells
[root@buildroot etc]#
[root@buildroot etc]#
可以看到,提示符已经修改过来。但这样修改,系统重启后,还会变回默认。
所以要将这部分写在系统中,在系统初始化的时候,自动加载。
- 在/etc/profile.d/新建env.sh,进行PS1设置 (提供在调用以上profile的时候,默认加载/etc/profile.d/目录下的所有.sh文件)
[root@buildroot profile.d]#cd /etc/profile.d/
[root@buildroot profile.d]#ls
env.sh umask.sh
[root@buildroot profile.d]#
env.sh内容
export PS1="\[\e[1;36m\][\u@\h \W]\\$\[\e[0m\]"
或者:(小写w和大写W有区别哦)
export PS1="\[\e[1;36m\][\u@\h \w]\\$\[\e[0m\]"
这样系统在重启之后,PS1也会自动加载!
- 也有一种方式,在编译burildroot的时候,将env.sh直接编译到根文件系统中
将env.sh,放到以下目录,再进行编译,重新烧录镜像即可!
eric@eric-PC:~/Documents/linux-c/buildroot-2020.02.1/output/target/etc/profile.d$ ls -l
总用量 8
-rw------- 1 eric eric 48 5月 3 09:52 env.sh
-rw-r--r-- 1 eric eric 10 4月 11 04:42 umask.sh
eric@eric-PC:~/Documents/linux-c/buildroot-2020.02.1/output/target/etc/profile.d$