.bash_profile & .bashrc

 

转自:http://www.cnblogs.com/FrankTan/archive/2011/01/09/1931416.html


   经常有人问我.bashrc和.bash_profile的区别,在这里把它写出来。

 

   .bash_profile是在登陆的时候才会执行的,它也可以叫做.bash_login,也就是说你在命令行再运行bash命令的时候是不会执行这个文件里面的命令的。

   而.bashrc恰好相反,是在执行子shell(sub-shell)的时候才会执行里面的命令。

 

   现在默认的.bash_profile大多都有这么一句:

 

   
# Get the aliases and functions
if [ -~/.bashrc ]; then
        . 
~/.bashrc
fi

 

 

所以登陆的时候也会执行到.bashrc里面的命令。

 

posted on 2012-04-16 13:15  Orz..  阅读(75)  评论(0)    收藏  举报

导航