.bash_profile、.profile、.bashrc 文件的区别
配置文件的分类
-
设置系统全局环境变量:
~/etc/profile、~/etc/bashrc -
设置用户环境变量:
~/.bash_profile、~/.profile、~/.bashrc
配置文件的优先级
当登入系统时候获得一个 shell 进程时,其读取环境配置的流程为:
从
~/etc/profile读入全局环境变量,并根据其内容读取额外的配置,如~/etc/profile.d和~/etc/inputrc-
根据 shell 的类型读取用环境变量
当 shell 为交互式登陆 shell 时,按照
~/.bash_profile-->~/.bash_login-->~/.profile-->~/.bashrc的顺序读取当 shell 为交互式非登陆 shell 时,读取
~/.bashrc当 shell 为**非交互式 shell **时,读取环境变量
BASH_ENV指定的配置文件
~/.bash_profile、~/.bash_login、~/.profile只在会话开始时被读取一次,而~/.bashrc则每次打开新的终端时都会被读取。