login与non-login shell
-
login shell:取得 bash 时需要完整的登陆流程的,就称为 login shell。举例来说,你要由 tty1 ~ tty6
登陆,需要输入用户的账号与密码,此时取得的 bash 就称为『 login shell 』;
-
non-login shell:取得 bash 接口的方法不需要重复登陆,举例来说,(1)以 X window 登陆 Linux 后,
再以 X 的图形化接口启动终端机,此时那个终端接口并没有需要再次的输入账号与密码,那个 bash 的环境就称为
non-login shell了。(2)在原本的 bash 环境下再次下达 bash 这个命令,同样的也没有输入账号密码,
那第二个 bash (子程序) 也是 non-login shell 。
login shell 其实只会读取这两个配置文件:
-
/etc/profile:这是系统整体的配置文件,最好不要修改这个文件;
-
~/.bash_profile 或 ~/.bash_login 或 ~/.profile:属于使用者个人配置,要改自己的数据,就写入这里!
/etc/profile (login shell 才会读)
~/.bash_profile (login shell 才会读)
bash在读取完了/etc/profile后,会去读取~/.bash_profile。
-
~/.bash_profile
-
~/.bash_login
-
~/.profile
其实 bash 的 login shell 配置只会读取上面三个文件的其中一个,
而读取的顺序则是依照上面的顺序。也就是说,如果 ~/.bash_profile 存在,那么其他两个文件不论有无存在,都不会被读取。
如果 ~/.bash_profile 不存在才会去读取 ~/.bash_login,而前两者都不存在才会读取 ~/.profile 的意思。
source :读入环境配置文件的命令
由于 /etc/profile 与 ~/.bash_profile 都是在取得 login shell 的时候才会读取的配置文件,所以,
如果你将自己的偏好配置写入上述的文件后,通常都是得注销再登陆后,该配置才会生效。利用 source 或小数点 (.) 都可以将配置文件的内容读进来目前的 shell 环境中。
阅读(562) | 评论(0) | 转发(0) |