bashrc,profile等文件的执行时机
bashrc,profile等文件的执行时机
bashrc,profile等文件的执行时机
在/etc,/home/username目录的bashrc,profile文件加上以下代码,
Shell代码
echo `date` >> /home/zhennn/priority
echo "/home/zhennn/.bashrc" >> /home/zhennn/priority
echo >> /home/zhennn/priority
观察一下它们的执行顺序。
做两个操作1)打开一个终端、2)用终端登录用户(su - zhennn)
Vim代码
2013年 07月 18日 星期四 00:32:56 CST
/etc/bash.bashrc
2013年 07月 18日 星期四 00:32:56 CST
/home/zhennn/.bashrc
2013年 07月 18日 星期四 00:33:29 CST
/etc/bash.bashrc
2013年 07月 18日 星期四 00:33:29 CST
/etc/profile
2013年 07月 18日 星期四 00:33:29 CST
/home/zhennn/.bashrc
2013年 07月 18日 星期四 00:33:29 CST
/home/zhennn/.profile
所以一个用户进入一个终端时会执行一次bashrc,而且/etc先于 /home/username的。
当用户登录时profile也会被执行,同个目录中bashrc先于profile。
评论暂时关闭