All posts
Article · 1 min ·

Linux: The '/proc' Filesystem

In Linux, everything is a file. Even processes.

Don't believe me? Open your terminal.

Exploring /proc

Go to /proc. You will see numbered directories.

cd /proc
ls
# 1  123  456 ...

These numbers are PIDs (Process IDs). Directory 1 is the init process (or systemd).

Hacking a Process

Let's say Python is running. Find its PID.

pgrep python
# 1234

Go to /proc/1234.
* cmdline: The command that started it.
* environ: The environment variables (Secrets! 🤫).
* fd: File descriptors (files it has opened).

Conclusion

If you want to know what a program is doing, don't guess. Look at /proc. It's the dashboard of the kernel.

Related posts