login shell:取得 bash
时需要完整的登录流程。就是说通过输入账号和密码登录系统,此时取得的 shell
称为login shell
。
non-login shell:取得sbash接口的方法不需要重复登录的举动。如以 X Window
登录 linux
后,再以X的图形界面启动终端机,此时那个终端机并没有需要输入账号和密码,那个 bash
环境就是 non-login shell
。在原本的 bash
环境下再次执行bash命令,同样也没有输入账号密码就进入新的 bash
环境(前一个 bash
的子进程),新的 bash
也是 non-login shell
。
那么,到底两者的区别在哪里?
login shell
:此种方式登录时,shell
会重新读取/etc/profile和~/.bash_profile来应用新的环境变量。
non-login shell
:此时 shell
不会读取 /etc/profile
和 ~/.bash_profile
,而是读取 ~/.bashrc
来应用新的环境变量。
当以
non-login shell
登录时,如果希望获取用户的环境变量,执行source ~/.bash_profile
即可。