Centos7使用/etc/profile.d设置环境变量,不使用/etc/profile设置环境变量
一、使用/etc/profile.d而不使用/etc/profile的原因
- 如下图所示,使用/etc/profile.d,需要变量单独建立对应shell脚步,例如java.sh,node.sh,变量之间相互不干扰,不需要可以直接删除。
-
能像上面在/etc/profile.d目录下设置环境变量的原因,主要是因为/etc/profile会在每次启动时自动加载 profile.d 下的每个变量配置,如下图所示
-
可以单独激活/etc/profile.d目录下的变量,例如source node.sh