所有用户的永久环境变量


11

我想让系统上的所有用户都拥有一个名为SPI的环境变量,该变量指向/ usr / local / share_ideas目录。我该怎么做?

Answers:


16

我将其放在文件的/ etc目录中/etc/profile.d/myvariable.sh。在此文件中,我将其设置如下:

SPI=/usr/local/share_ideas

/etc/profile.d目录中的文件会作为用户登录系统的一部分自动获得。bash shell使用以“ .sh”结尾的文件。


4
为什么不在/etc/profile?是否有使用/etc/profile.d文件更好的特定原因?
terdon

11
如果/etc/profile由于更新RPM 而使获取的内容得到更新。这是一个远程问题,但最好不要保留系统级文件,这样您的更改就不会丢失。
slm
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.