bash的配置文件:
按生效范围划分,存在两类:
全局配置:
/etc/profile
/etc/profile.d/*.sh
/etc/bashrc
个人配置:
~/.bash_profile
~/.bashrc
按功能划分,存在两类:
profile类: 为交互式登录的shell提供配置
全局: /etc/profile, /etc/profile.d/*.sh
个人: ~/.bash_profile
功用:
(1) 定义环境变量;
(2) 运行命令或脚本;
bashrc类: 为非交互式登录的shell提供配置
全局: /etc/bashrc
个人: ~/.bashrc
功用:
(1) 定义命令别名;
(2) 定义本地变量;
shell登录:
交互式登录:
直接通过终端输入账号密码登录;
使用"su - UserName"或"su -l UserName"切换的用户
读取次序:
/etc/profile --> /etc/profile.d/*.sh --> ~/.bash_profile --> ~/.bashrc --> /etc/bashrc
非交互式登录:
su UserName
图形界面下打开的终端
执行脚本
读取次序:
~/.bashrc --> /etc/bashrc --> /etc/proile.d/*.sh