buildroot编译树莓派0-修改PS1

  • 增加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$ 


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值