Quick Linux Tip #117:
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 - $
sudo ls -la /proc/3456/cwd# Inspect the current working directory of the process - $
sudo readlink /proc/3456/exe# Resolve the absolute path to the running binary
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).
Leave a Reply