linux中profile的執行說明

來源:互聯網
上載者:User
(1)/etc/profile全域(公有)配置,不管是哪個使用者,登入時都會讀取該檔案。 (2)/ect/bashrcUbuntu沒有此檔案,與之對應的是/ect/bash.bashrc它也是全域(公有)的,bash執行時,不管是何種方式,都會讀取此檔案。 (3)~/.profile若bash是以login方式執行時,讀取~/.bash_profile,若它不存在,則讀取~/.bash_login,若前兩者不存在,讀取~/.profile。另外,圖形模式登入時,此檔案將被讀取,即使存在~/.bash_profile和~/.bash_login。 (4)~/.bash_login若bash是以login方式執行時,讀取~/.bash_profile,若它不存在,則讀取~/.bash_login,若前兩者不存在,讀取~/.profile。 (5)~/.bash_profileUnbutu預設沒有此檔案,可建立。只有bash是以login形式執行時,才會讀取此檔案。通常該設定檔還會配置成去讀取~/.bashrc。 (6)~/.bashrc當bash是以non-login形式執行時,讀取此檔案。若是以login形式執行,則不會讀取此檔案。 (7)~/.bash_logout登出時,且是longin形式,此檔案才會讀取。也就是說,在文字模式登出時,此檔案會被讀取,圖形模式登出時,此檔案不會被讀取。 下面是在原生幾個例子:1. 圖形模式登入時,順序讀取:/etc/profile和~/.profile2. 圖形模式登入後,開啟終端時,順序讀取:/etc/bash.bashrc和~/.bashrc3. 文字模式登入時,順序讀取:/etc/bash.bashrc,/etc/profile和~/.bash_profile4. 從其它使用者su到該使用者,則分兩種情況:(1)如果帶-l參數(或-參數,--login參數),如:su -l username,則bash是lonin的,它將順序讀取以下設定檔:/etc/bash.bashrc,/etc/profile和~ /.bash_profile。(2)如果沒有帶-l參數,則bash是non-login的,它將順序讀取:/etc/bash.bashrc和~/.bashrc5. 登出時,或退出su登入的使用者,如果是longin方式,那麼bash會讀取:~/.bash_logout6. 執行自訂的shell檔案時,若使用“bash -l a.sh”的方式,則bash會讀取行:/etc/profile和~/.bash_profile,若使用其它方式,如:bash a.sh, ./a.sh,sh a.sh(這個不屬於bash shell),則不會讀取上面的任何檔案。7. 上面的例子凡是讀取到~/.bash_profile的,若該檔案不存在,則讀取~/.bash_login,若前兩者不存在,讀取~/.profile。
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.