How to permanently export a variable in Linux?

user1340582 picture user1340582 · Oct 24, 2012 · Viewed 262.5k times · Source

I am running RHEL6, and I have exported an environment variable like this:

export DISPLAY=:0

That variable is lost when the terminal is closed. How do I permanently add this so that this variable value always exists with a particular user?

Answer

Antoine picture Antoine · Oct 24, 2012

You can add it to your shell configuration file, e.g. $HOME/.bashrc or more globally in /etc/environment. After adding these lines the changes won't reflect instantly in GUI based system's you have to exit the terminal or create a new one and in server logout the session and login to reflect these changes.