bash配置文件的分两大类:
1,全局配置,比如:/etc/profile, /etc/profile.d/*.sh, /etc/bashrc
2,个人配置,比如:~/.bash_profile, ~/.bashrc
其中,profile类的文件记录的是:1,设定环境变量; 2,运行命令或脚本;
bashrc类的文件记录的是:1,设定本地变量;2,定义命令别名。
bash配置文件的加载顺序分两种,登录式shell和非登录式shell。
1,登陆式shell是指:1,正常通过终端登录;2,su - username;3,su -l username;
执行顺序是:/etc/profile -> /etc/profile.d/*.sh -> ~/.bash_profile -> ~/.bashrc -> /etc/bashrc
2,非登录式shell是指:1,su username;2,图形终端下的打开命令窗口;3,自动执行的shell脚本;
执行顺序是:~/bashrc -> /etc/bashrc -> /etc/profile.d/*.sh