bash的配置文件:
- 按生效范围划分:
全局配置:/etc/profile和/etc/profile.d(/etc/profile.d是个目录,里面存放的是以.sh结尾的 shell脚本文件)
个人配置:~/bash_profile和~/bashrc
2. 按功能划分:
profile类:为交互式登陆的shell提供配置(定义环境变量、需要执行的脚本);
bashrc类:为非交互式登陆的shell提供配置(定义别名、本地变量);
shell登陆:交互式登陆、非交互式登陆
- 交互式登陆:
1. 直接通过终端输入账号密码登陆;
2. 使用su - UserName或su -l UserName或su --login UserName登陆;通过man su查看命令, 如下图:可知会初始化环境变量。
2. 非交互式登陆:
1. su UserName;
2. 图形界面下打开的终端;
3. 执行脚本;
交互式登陆的执行流程:/etc/profile ---> /etc/profile.d ---> ~/bash_profile ---> ~/bashrc ---> /etc/bashrc。
非交互式登陆的执行流程:~/bashrc ---> ~/bash_profile ---> /etc/profile.d/*.sh