I am running RHEL 6, 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?
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 systems. You have to exit the terminal or create a new one and on the server, log out the session and log in to reflect these changes.
However, you may also execute ~/.bashrc
manually using the bash builtin source
.
$ source ~/.bashrc
For other shells, consult documentation for analogous commands.