brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: tr on /proc/PID/environ shows the environment of a running linux process

Linux
~/tips/tip-linux-proc-pid-environ

tr '\0' '\n' < /proc/$(pgrep -o nginx)/environ | sort

Prints the variables a running process was started with, one per line.

A service behaves differently from my shell, and I want to see the variables it was started with.

tr '\0' '\n' < /proc/$(pgrep -o nginx)/environ | sort

The environment is stored in /proc/PID/environ as entries separated by NUL bytes, so tr turns them into lines. You can read it for your own processes, and for others as root. The file shows the environment at the time the process started. Changes the program made later with setenv do not appear.

Further reading: proc_pid_environ manual page

More Linux tips a2query -m rewrite renice -n 10 -p 4242 cat config.yml | xsel -ib xvfb-run -a your-program --some-flag dpkg --get-selections > packages.txt All Linux tips (261) All topics

Link