解析login shell和no-login shell

來源:互聯網
上載者:User

解析login shell和no-login shell login shell:取得bash 時需要完整的登入流程,就稱為login shell。舉例來說,同tty1~tty6登入時, 需要輸入使用者名稱和密碼,此時取得的bash就稱為login shell non-login shell:取得bash介面的方法不需要重複登入的動作。 舉兩個例子(1)以X window登入linux後,再以X 的圖形化介面啟動終端機,此時那個終端機並不需要再次的輸入使用者名稱和密碼,那個bash的環境就稱為non-login shell(2)在原本的bash環境中再次下達bash這個指令,同樣沒有要求輸入使用者名稱和密碼,那個第二個bash也是non-login shell login shell 和 no-login shell 的執行順序:Login shells:/etc/profile    /etc/profile.d~/.bash_profile    ~/.bashrc          /etc/bashrc Non-login shells:~/.bashrc    /etc/bashrc          /etc/profile.d 注意:/etc/profile:整個系統的環境放在~裡的是個人設定,一般放在~/.bashrc 如果想執行目前的目錄的指令碼,有2種方法: 可以運行./script.sh  (需要有可執行許可權)(1)使bash新產生一個子bash來執行,例如:./script.sh (需要有可執行許可權)。在此情況下, 指令碼對環境變數的更改只對子bash有效.(2) 可使用source命令來直接執行指令碼(可用'.'來代替source). 它與上面的方法有兩點區別:     1, 指令檔不需要執行許可權.     2, 就在當前bash中執行, bash不會新fork一個子bash來執行它, 所以指令碼對環境變數的更改會影響到當前bash.所以當希望使修改的環境變數生效,用source即可。 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.