登录shell与非登录shell

来源:互联网 发布:足球大数据分析 编辑:程序博客网 时间:2024/05/18 11:48

::登录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

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