In this lesson, you will learn how to peer directly into the kernel's brain to retrieve real-time statistics about any running process.
The Window into the Kernel
The /proc directory is a "virtual" filesystem. Unlike your hard drive, which stores static files, /proc doesn't actually exist on your disk. Instead, the Linux kernel generates these files on the fly as a way to expose information about the system. Think of it as a live control panel where every running process has its own dedicated folder, named after its Process ID (PID).
Exploring Process Statistics
Every time you launch a program, the kernel assigns it a PID. If you want to know what that process is doing, you don't need a special monitoring tool; you just look inside /proc/[PID]/.
For example, let's look at your current shell process. You can find its PID by typing echo $$. If your PID is 1234, you can inspect its status by running:
cat /proc/1234/status
When you run this, the kernel dynamically generates a text file containing the process's name, its current state (like "sleeping" or "running"), how much memory it is using, and even its user credentials.
Why is this powerful?
Because these files act like standard text files, you can use regular command-line tools to monitor processes. You could use grep to filter for memory usage or use cat to see the command line arguments used to start the process:
# See the exact command that started the process
cat /proc/1234/cmdline
If the process terminates, its corresponding directory in /proc vanishes instantly. This provides a live, reliable, and standardized way to inspect the internal state of your system without needing external software. You are effectively reading the kernel's own internal bookkeeping directly from the source.
Key Takeaway: The /proc filesystem provides a virtual window into the kernel, allowing you to access live process data simply by reading files named after process IDs.