还我彩色ls
Debian安装好之后发现ls不是彩色的… 察看了一下.bashrc里面确实有设置 alias ls=’ls –color=auto’ 郁闷。偶尔发现如果再执行一次bash就正常了。我想可能是和这几个初始文件的执行顺序有关系吧,google了一下查到了一些资料:
Re: I’m really confused by bash, .bashrc, .bash_profile, .profile, etc,
Each of these files are read by bash at different times: .bash_profile is executed when you login. Stuff you put in there might be your PATH and other important environment variables. .bashrc is used for non login shells. I’m not sure what that means. I know that RedHat executes it everytime you start another shell (su to this user or simply calling bash again) You might want to put aliases in there but again I am not sure what that means. I simply ignore it myself. .profile is the equivalent of .bash_profile for the root. I think the name is changed to let other shells (csh, sh, tcsh) use it as well. (you don’t need one as a user) There is also .bash_logout wich executes at, yeah good guess…logout. You might want to stop deamons or even make a little housekeeping . You can also add “clear” there if you want to clear the screen when you log out.
也就是说我Login是不会执行.bashrc的,解决方法是把.bash_profile中注释掉的行取消注释就搞定了 :)
其实其中实际起作用的一行就是 . ~/.bashrc
Update: 我在O’reilly的”Learning Debian GNU/Linux”中看到了解释:
| Script | Function |
|---|---|
| /etc/profile | Executed when the user logs in |
| ~/.profile | Executed when the user logs in |
| ~/.bashrc | Executed when BASH is launched |
| ~/.bash_logout | Executed when the user logs out |