站在用戶登錄的角度來說,SHELL的類型
登錄式shell
正常通過某終端登錄
su - USERNAME
su -l UASENAME
非登錄式shell
su USERNAME
圖形終端下打開命令窗口
自動執行的shell腳本
bash的配置文件
全局配置
/etc/profile , /etc/profile.d/*.sh , /etc/bashrc
個人配置
~/.bash_profile , ~/.bashrc
login shell:
1. /etc/profile 系統級別配置文件
2. ~/.bash_profile 用戶級別配置文件 (用戶自定義的環境變量)
3. ~/.bashrc 用戶級 (定義別名)
4. /etc/bashrc 系統級
non-login shell:
1. ~/.bashrc 用戶級
2. /etc/bashrc 系統級
profile類的文件
設定環境變量
運行命令或腳本
bashrc類的文件
設定本地變量
定義命令別名
登錄式shell如何讀取配置文件
/etx/profile -- > /etc/profile.d/*.sh -- > ~/.bash_profile -- > ~/.bashrc -- > /etc/bashrc
非登錄式shell如何讀取配置文件
~/.bashrc -- > /etc/basrc -- > /etc/profile.d/*.sh