Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to view environment of process

📅 2016-Sep-28 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ process ⬩ 📚 Archive

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

© 2023 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘📧