Centos有4個地方存儲環境變量:/etc/profile /etc/bashrc ~/.bash_profile ~/.bashrc
/etc/profile:定義了系統環境變量
pathmunge()函數如果第二個參數是“after”,PATH=$PATH:$1
設置MAIL路徑為/var/spool/mail/$USER
設置root帳號的環境變量
設置HISTCONTROL
聲明 PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL為環境變量
設置umask
循環調用/etc/profile.d/.sh
/etc/bashrc:設置函數和別名
設置PS1
設置umask
循環調用/etc/profile.d/.sh
~/.bash_profile
調用~/.bashrc
設置本地環境變量
~/.bashrc
定義別名
設置PS1
調用/etc/bashrc
調用順序:
交互式登錄:/etc/profile –> /etc/profile.d/.sh –> ~/.bash_profile–> ~/.bashrc–> /etc/bashrc
非交互式登錄:~/.bashrc–> /etc/bashrc–> /etc/profile.d/.sh
原創文章,作者:realmaster,如若轉載,請注明出處:http://www.www58058.com/70489