root/下的.bashrc_.bash_profile使用

本文介绍了Bash配置文件.bash_profile和.bashrc的使用方法,包括条件语句的应用及如何通过这些文件自动化启动指定脚本,提高调试效率。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[ root@localhost root]# cat .bash_profile
#!/bin/sh
if [ -f ${HOME}/.bashrc ] //如果当前目录存在.bashrc   -f表示文件
then
    . ${HOME}/.bashrc     //就执行.bashrc
fi                        //结束,与前一个if对应。
if [ -d ${HOME}/modules ] //如果当前目录存在modules目录,-d表示目录
then
    cd ${HOME}/modules        //进入modules目录
    if [ -f ${HOME}/modules/load_modules.sh ]    //如果存在load_modules.sh
    then
        . ${HOME}/modules/load_modules.sh       //则执行
        cd ${HOME}                              //切换目录
        ./main_sdk7105_7105_ST40_LINUX_32BITS.out   //执行
    fi
#    if [ -f ${HOME}/modules/staudlx_aic3104.ko ]
#    then
#        /sbin/insmod ${HOME}/modules/staudlx_aic3104.ko
#    fi
fi
[root@localhost root]#
 
${HOME} :表示当前目录
这里面有意思的就是 if then fi语句的应用~ 只要root登陆进来,脚本就会自动运行。非常方便,可以极大提高调试效率。
 
[root@localhost root]# cat .bashrc
# root .bashrc file
DISPLAY=:0
export PATH DISPLAY
alias ls="ls -F --color=auto"
ulimit -c 0
[root@localhost root]#

经常编辑vim的时候会用到.bashrc。
 
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值