How to view environment of process

Sometimes you might be curious to find out the environment variables and values of a running process.

This is easy to do with the ps command, by providing the PID of the process (say 9999):

$ ps eww 9999

The ps command on Linux relies heavily on the /proc pseudo filesystem to gather almost all of its information on processes. So, as you might guess you can get the exact same environment that ps prints from /proc. Just provide the PID, say 9999:

$ cat /proc/9999/environ

Tried with: Ubuntu 14.04

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.