Show environment variables of a process

 ยท 1 min ยท torgeir

Use ps -E to list the environment variables of a process.

Terminal

Run a program with some environment variable.

SAY_WHAT=1 sleep 20 &
[1] 9929

Use ps -E to show the environment variables it started with. Use $! to refer the last started pid (program id). Pass it through cat to wrap long lines.

ps -E $! | cat
9929 ttys000    0:00.01 sleep 20 ALACRITTY_LOG=/var/folders/8v .... SAY_WHAT=1 ....

Nifty ๐Ÿ”Ž