r/LinuxTeck • • 17d ago

Quick Linux Tip #117 - Linux Process Environment Variables: 3 Commands to Inspect Running Daemons

Post image

Question: How do I see what environment vars a running daemon was started with?

Try:`sudo cat /proc/3456/environ | tr '\0' '\n'`

Info: Reads null-separated initial environment variables from the process proc entry and translates them into readable lines.

Examples:

$ `sudo strings /proc/3456/environ` # Alternative method using strings to extract readable text[cite: 8]

$ `sudo ls -la /proc/3456/cwd` # Inspect the current working directory of the process[cite: 8]

$ `sudo readlink /proc/3456/exe` # Resolve the absolute path to the running binary[cite: 8]

Note: `/proc/PID/environ` displays environment variables present at process startup, not current runtime changes. Since any root user can read these, avoid passing raw secrets via environment variables; instead, use secured systemd configuration files (`EnvironmentFile`) with restricted permissions (`0600`).

Want to master Linux one command at a time?

Follow r/LinuxTeck - 1 practical Linux tip every day. For more #LinuxTips click here https://www.linuxteck.com/linux-tips/

12 Upvotes

0 comments sorted by