天天看點

Linux中login shell和non-login shell

  • login shell:需要輸入使用者的帳号與密碼,此時的bash就稱為“login shell”。
  • non-login shell:在原本的bash環境下再次執行bash這個指令,沒有輸入帳号和密碼,那第二個bash(子程序)就是“non-login shell”。

login shell 的讀取流程

Linux中login shell和non-login shell
從上圖可以看出來,最終被讀取的配置檔案是~/.bashrc這個檔案。是以可以将自己的偏好設定寫入該檔案即可。

non-login shell 非登入情況

當取得non-login shell時,這個bash僅會讀取~/.bashrc而已。預設的~/.bashrc内容如下:

Linux中login shell和non-login shell
注意:我這裡用的是root身份取得的上述資料,如果是一般的使用者的./bashrc會有些不同。

繼續閱讀