12

I want to have all users on the system to have an environment variable named SPI that points to /usr/local/share_ideas directory. How do I do it?

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
Philip
  • 121
  • 1
  • 1
  • 3

1 Answers1

17

I'd put it in the /etc directory in the file /etc/profile.d/myvariable.sh. In this file I'd set it like this:

SPI=/usr/local/share_ideas

Files in the /etc/profile.d directory are automatically sourced as part of a user logging into the system. The files that end in a ".sh" are used by the bash shell.

slm
  • 363,520
  • 117
  • 767
  • 871
  • 4
    Why not in `/etc/profile`? Is there a specific reason that using `/etc/profile.d` files is better? – terdon Apr 29 '13 at 18:02
  • 11
    In case the `/etc/profile` get's updated as a result of an update to an RPM. This is a remote issue but better to leave the system level files alone so your changes don't get lost. – slm Apr 29 '13 at 18:06