Ben L Ben L - 1 year ago 93
Linux Question

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.

Answer Source

The kernel stores the list of environment variables and their values for each process, and inherit them to child processes. They exist at runtime, and are not stored in some file or so. But there is a virtual file in


Which contains all the environment variables. The kernel makes them visible by that virtual file. One can list them. For example to view the variables of process 3940, one can do

cat /proc/3940/environ | tr '\0' '\n'

Each variable is delimited by a binary zero from the next one. tr replaces the zero into a newline.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download