.bash_profile vs .bashrc && /etc/profile vs /etc/bashrc
2011-08-08 18:49
381 查看
.bash_profile and .bashrc
According to the bash man page, .bash_profile is executed for login shells, while .bashrc is executed for interactive non-login shells.Say, you’d like to print some lengthy diagnostic information about your machine each time you login (load average, memory usage, current users, etc). You only want to see it on login, so you only want to place this in your .bash_profile. If you put it in your
.bashrc, you’d see it every time you open a new terminal window.
Most of the time you don’t want to maintain two separate config files for login and non-login shells — when you set a PATH, you want it to apply to both. You can fix this by sourcing .bashrc from your .bash_profile file, then putting PATH and common settings
in .bashrc.
To do this, add the following lines to .bash_profile:
隐藏行号 复制代码 ?
Add the following line
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
function CopyCode(key){var codeElement=null;var trElements=document.all.tags("ol");var i;for(i=0;i
Now when you login to your machine from a console .bashrc will be called.
/etc/profile and /etc/bashrc
/etc/profile is read in automatically only if the shell is a login shell./etc/profile contains system/global environment variables and startup programs. Since environment variables are persistent (each process started by a shell inherits them) it’s only needed to read them once. Similarly, once a startup program is launched, there
is no need to start it again.
Since /etc/bashrc is included by ~/.bashrc, and read every
time a shell starts up, people use it to include shell aliases and functions.
相关文章推荐
- profile && login && bash_profile && bashrc的区别
- 浅析linux 下的/etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc
- 浅析linux 下的/etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc 文件
- linux环境变量设置,/etc/profile,/etc/bashrc和.bash_profile的区别(作用域)
- Linux中的~/.profile,~/.bashrc,/etc/profile,/etc/bash.bashrc
- 详解/etc/profile、/etc/bash.bahsrc、~/.profile、~/.bashrc的用途
- 【每天一个linux命令】11. Linux配置环境变量/etc/profile .bashrc .bash_profile等
- /etc/profile和/etc/bashrc和~/.bash_profile和~/.bashrc和~/.bash_logout的区别
- linux 下/etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc 文件的区别
- 【每天一个linux命令】11. Linux配置环境变量/etc/profile .bashrc .bash_profile等
- 启动文件rc.local、/etc/bash.bashrc、~/bashrc、/etc/profile、~/.profile【转载from joyride】值得了解
- 浅析linux 下的/etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc 文件
- profile bashrc bash_profile 之间…
- shell的初始化文件:/etc/profile和/etc /bashrc(bash.bashrc)
- 【shell】/etc/bashrc、~/.bashrc、~/.bash_profile的区别和作用
- 浅析linux下的/etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc文件
- 浅析linux 下的/etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc 文件
- 浅析linux 下的/etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc
- 环境配置文件 ① /etc/profile、② ~/.bash_profile、③ ~/.bashrc、④ /etc/bashrc
- 【每天一个linux命令】11. Linux配置环境变量/etc/profile .bashrc .bash_profile等