Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using Red Hat. I need to export variables for all users (permanently). How would I go about doing that? I know there is a file for a single user where I can set permanent variables.

share|improve this question

migrated from Sep 25 '12 at 3:11

This question came from our site for professional and enthusiast programmers.

up vote 8 down vote accepted

You can put the variable assignments in one of the shell startup scripts:


for bash and some other shells, depending on how your particular distro is configured. There are equivalents for most shells. There is also a file


which is not a script but contains enviroment variable assignments, and is loaded at login via Obviously this works only on systems that use PAM for authentication (almost all Linux distros, but probably not Solaris).

share|improve this answer
Solaris uses PAM; whether it's version of PAM uses /etc/environment is a separate issue. – Jonathan Leffler Sep 25 '12 at 3:15

Aside from /etc/profile, etc., adding a script into /etc/profile.d to achieve your feature is ideal because it works well with packagers which expect to be able to install and uninstall.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.