您的位置:首页 > 运维架构 > Shell

验证bash的配置文件加载顺序

2013-07-18 18:54 295 查看
系统版本:Red Hat Enterprise Linux Server release 6.2 (Santiago)

实验准备:
--------------[root@db1 ~]# for file in /etc/profile /etc/profile.d/a.sh ~/.bash_profile ~/.bashrc /etc/bashrc;do touch $file;mv $file $file.bak ;echo ' echo '$file' load start @ `date +%S.%N`' >> $file; cat $file.bak >>$file;echo ' echo '$file' load finished @ `date +%S.%N`' >> $file;done--------------

结果:
login shell:
[root@db1 ~]# su - root/etc/profile load start @ 00.342533947/etc/profile.d/a.sh load start @ 00.375653156/etc/profile.d/a.sh load finished @ 00.386663719/etc/profile load finished @ 00.459338038/root/.bash_profile load start @ 00.472126516/root/.bashrc load start @ 00.501099137/etc/bashrc load start @ 00.517663430/etc/bashrc load finished @ 00.530761110/root/.bashrc load finished @ 00.548283973/root/.bash_profile load finished @ 00.567944143

非login shell:
[root@db1 ~]# su root
/root/.bashrc load start @ 22.772783963/etc/bashrc load start @ 22.785428207/etc/profile.d/a.sh load start @ 22.801624494/etc/profile.d/a.sh load finished @ 22.816499465/etc/bashrc load finished @ 22.881630850/root/.bashrc load finished @ 22.892364478





图示:(时间重叠部分体现了相互调用关系)



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: