在linux系统中配置环境变量的地方有很多,但他们有什么区别?
-
首先bash的运行模式分为login shell 和 non-login shell
-
通过终端使用账号密码登录的就是login shell模式,例如我们使用xshell连接。
-
而ssh就是一种non-login shell。
-
-
区别:
-
login shell在启动的时候会加载:
-
/etc/profile
-
~/.bash_profile
-
~/.bashrc
-
-
non-login shell在启动时只加载 ~/.bashrc
-
-
在~/.bashrc中会加载/etc/profile.d/*.sh,也就是说不管是login shell还是non-login shell,启动时都会加载/etc/profile.d/下的环境变量。