天天看點

登入shell與非登入shell

::登入shell

::非登入shell

--------------

1>su tao   //非登入shell  注意: su - root -->這将是一個登入shell !

2>bash      //非登入shell

3>重新打開一個終端!  //非登入shell!

--------------->

========================

執行登入 shell 的時候,需要用到的環境變量配置檔案!

登入 (5個檔案!)

step1> /etc/profile   ///最後面添加一個變量!  logout 之後, 就可以列印那個變量的值了!  var=200 ! 注意, /etc/profile 也會調用 /etc/profile.d/*.sh -->在後面!

step2> /etc/profile.d/*.sh  ///自己在目錄 /etc/profile 建立一個新的 sh 檔案,然後賦予可執行權限,然後 logout ,就可以驗證了!  聲明一個變量: var=100

step3> ~/.bash_profile  ///個人宿主目錄下面的隐藏檔案!  var=300 (私人的! ) ==>注意看檔案中的一條 if 語句,如果有 .bashrc 檔案,會執行 .bashrc !

     \---> .bash_profile與 .bashrc 的關系是一個調用關系!

       \---> .bash_profile 的執行步驟是第三步,隻是檔案裡面會調用 .bashrc 檔案 !

step4> ~/.bashrc   /// .bashrc 裡面也會調用全局的  /etc/bashrc 檔案 !

step5> /etc/bashrc

登入shell>

登入的時候,下面的5個檔案将被執行!順序以及關系如下!

/etc/profile ----調用--->/etc/profile.d/*.sh ---------->.bash_profile ---------調用----->.bashrc-------調用------>/etc/bashrc

非登入shell>

/etc/profile.d/*.sh-->~/.bashrc-->/etc/bashrc

==========================================

退出shell的時候,會去執行的環境變量的配置檔案是:  ~/.bash_logout

======================================================================