login shell与non-login shell:

         login shell:取得shell时,需要完整的登入流程。如:tty1~tty6登入时,需要输入用户名和密码。此时取得的shell就称为login

                          shell。

         non-login shell:取得shell时,不需要重复登入的过程。如:以X window登入linux,再以X的图形界面启动终端机,此时终端

                                 机不需要再次的输入用户名和密码,这个bash的环境就是non-login shell。

                                 如:在原本的bash环境中再次下达bash这个命令,不要求输入用户名和密码,这个bash环境就是non-login

                                 shell。

 

interactive shell与non-interactive shell:

         交互式shell:shell等待命令,然后执行命令。如:用户登录--->执行命令......--->logout,shell也终止。

         非交互式shell:shell读取文件中的命令,执行命令,读到文件最后一行,shell终止。如shell脚本文件。

 

bashrc和profile都用于保存用户的环境信息,bashrc用于保存交互式的non-login shell,profile用于交互式的login shell。

         /etc/profile, /etc/bashrc 是系统全局环境变量设定。有的系统已经没有/etc/bashrc这个文件。

        ~/.profile, ~/.bashrc 是用户目录下的私有环境变量设定。~/.profile只是登入的时候执行一次,~/.bashrc每次打开一个shell

                                       都会被执行。

 

login shell的初始执行过程:/etc/profile 这个文件还自己调用 /etc/profiled/*sh  /etc/inpurc等。

                               ~/.bash_profile  ~/.bash_login  ~/.profile 依次调用各个文件,有一个执行后,即停止。

non-login shell的初始执行过程:~/.bashrc 这个文件自己调用 /etc/bashrc, /etc/bashrc再去调用 /etc/profiled/*sh等。     

 

相关文章:

  • 2022-01-28
  • 2021-11-01
  • 2021-04-20
  • 2021-10-06
  • 2021-12-26
  • 2021-10-30
  • 2021-05-29
猜你喜欢
  • 2021-07-09
  • 2021-12-21
  • 2022-12-23
  • 2021-11-24
  • 2022-12-23
  • 2022-01-22
相关资源
相似解决方案