The Magic of /proc: Your Kernel as a Filesystem

Share

One thing I still like about Linux is /proc. It is a virtual filesystem where the kernel exposes its own internals as ordinary files. Nothing is stored on disk; every time you read one of those files, the kernel works out the answer right then.

Want to inspect a running process? cat /proc/<pid>/status. Need to see which files it has open? ls -l /proc/<pid>/fd. The command line it was started with sits in /proc/<pid>/cmdline, and its full memory layout in /proc/<pid>/maps.

It goes further than that. /proc/cpuinfo and /proc/meminfo are where tools like htop read their numbers from. And /proc/sys is a live control panel: write a 1 to /proc/sys/net/ipv4/ip_forward and routing turns on immediately, with no reboot.

This is the old Unix idea in practice. When everything is a file, you do not need a hundred special APIs to inspect a system. You need cat, grep, and a bit of curiosity. Spend ten minutes poking around in there and you will understand your machine better than any dashboard will show you.