[linux] Linux: where are environment variables stored?

If I type into a terminal,

export DISPLAY=:0.0

... where is the shell storing that environment variable?

I'm using Ubuntu 8.10. I've looked in the files ~/.profile and /etc/profile and can find no trace of DISPLAY.

This question is related to linux environment-variables

The answer is


It's stored in the process (shell) and since you've exported it, any processes that process spawns.

Doing the above doesn't store it anywhere in the filesystem like /etc/profile. You have to put it there explicitly for that to happen.


If you want to put the environment for system-wide use you can do so with /etc/environment file.


That variable isn't stored in some script. It's simply set by the X server scripts. You can check the environment variables currently set using set.


Type "set" and you will get a list of all the current variables. If you want something to persist put it in ~/.bashrc or ~/.bash_profile (if you're using bash)