/etc/profile、/etc/profile.d、/etc/bashrc、~/bash_profile、~/bashrc的做用和執行順序

bash的配置文件:shell

  1. 按生效範圍劃分:

              全局配置:/etc/profile和/etc/profile.d(/etc/profile.d是個目錄,裏面存放的是以.sh結尾的   shell腳本文件)bash

              我的配置:~/bash_profile和~/bashrc變量

     2. 按功能劃分:配置

                profile類:爲交互式登錄的shell提供配置(定義環境變量、須要執行的腳本);file

                bashrc類:爲非交互式登錄的shell提供配置(定義別名、本地變量);終端

 

shell登錄:交互式登錄、非交互式登錄密碼

  1. 交互式登錄:  

            1. 直接經過終端輸入帳號密碼登錄;im

            2. 使用su - UserName或su -l UserName或su --login UserName登錄;經過man su查看命令,   以下圖:可知會初始化環境變量。配置文件

                

      2. 非交互式登錄:腳本

              1. su UserName;

              2. 圖形界面下打開的終端;

              3. 執行腳本;

 

交互式登錄的執行流程:/etc/profile ---> /etc/profile.d ---> ~/bash_profile ---> ~/bashrc ---> /etc/bashrc。

非交互式登錄的執行流程:~/bashrc ---> ~/bash_profile ---> /etc/profile.d/*.sh

相關文章
相關標籤/搜索