交互式Shell和非交互式Shellshell
登陸式Shell和非登陸式Shellbash
使用啓動腳本,可讓自定義的環境一勞永逸。spa
這些腳本在shell被建立時運行根據shell是登陸shell仍是非登陸shell,所運行的啓動腳本也會不同。code
su - username是登陸shell;su username是非登陸shell(注意su - username中間有空格)。直接打開終端是非登陸shell。blog
keegen@keegensCP:~$ su - keegen 密碼: keegen@keegensCP:~$ echo $0 -su keegen@keegensCP:~$ logout keegen@keegensCP:~$ echo $0 bash
/etc/profile 是登入shell啓動後運行的第一個啓動腳本,它只爲登入shell運行;非登入shell不會引起這個腳本。ip
登入shell加載啓動腳本的順序爲:
terminal
/etc/profile → /etc/profile.d → ~/.bash_profile → ~/.bashrc → /etc/bashrc
每一個調用的腳本會依次撤銷前一個調用腳本中的改變。it
在退出登入shell時,咱們還能夠執行某些任務,如建立自動備份、清除臨時文件。把這些任務放在.bash_logout文件中。class
非登入shell加載啓動腳本的順序:
登錄
~/.bashrc → /etc/bashrc → /etc/profile.d