.bash_profile、.profile、.bashrc 文件的區(qū)別
配置文件的分類
-
設置系統(tǒng)全局環(huán)境變量:
~/etc/profile、~/etc/bashrc -
設置用戶環(huán)境變量:
~/.bash_profile、~/.profile、~/.bashrc
配置文件的優(yōu)先級
當?shù)侨胂到y(tǒng)時候獲得一個 shell 進程時,其讀取環(huán)境配置的流程為:
從
~/etc/profile讀入全局環(huán)境變量,并根據(jù)其內(nèi)容讀取額外的配置,如~/etc/profile.d和~/etc/inputrc-
根據(jù) shell 的類型讀取用環(huán)境變量
當 shell 為交互式登陸 shell 時,按照
~/.bash_profile-->~/.bash_login-->~/.profile-->~/.bashrc的順序讀取當 shell 為交互式非登陸 shell 時,讀取
~/.bashrc當 shell 為**非交互式 shell **時,讀取環(huán)境變量
BASH_ENV指定的配置文件
~/.bash_profile、~/.bash_login、~/.profile只在會話開始時被讀取一次,而~/.bashrc則每次打開新的終端時都會被讀取。