linux环境变量优先级
登录shell类型
登录shell读取系统配置文件
- /etc/profile —/etc/profile.d/*.sh — ~/.bashrc ~.bash_profile – /etc/bashrc
非登录shell读取系统配置文件
- ~/.bashrc — /etc/bashrc — /etc/profile.d/*.sh
登录式shell怎么区别?
正常通过终端登录
- su -l username
- su - username
非登录shell
- su usrname
- 图形化打开窗口
- 自己执行的shell脚本
bash配置文件
全局配置
/etc/bashrc
/etc/profile
/etc/profile.d/*.sh个人配置
~/.bashrc
~/.bash_profileprofile文件
设定环境变量(个人的优先于全局的)
运行命令、脚本bashrc
设定本地变量
定义别名