The /proc filesystem
Unix systems have come a long way with
respect to providing uniform interfaces to different parts of
the system; as you will learn in the next chapter, hardware is
represented in Linux in the form of a special type of
file. There is, however, a special filesystem called the
/proc
filesystem that goes even one step
further: it unifies files and processes.
From the user’s or the system administrator’s point of
view, the /proc
filesystem looks just like
any other filesystem; you can navigate around it with the
cd command, list directory contents with the
ls command and view file contents with the
cat command. However, none of these files and
directories occupy any space on your hard disk. The kernel traps
accesses to the /proc
filesystem and
generates directory and file contents on the fly. In other
words, whenever you list or directory or view file contents in
the /proc
filesystem, the kernel
dynamically generates the contents you want to see.
To make this less abstract, let’s see some examples.
The following example displays the list of files in the top-level
directory of the /proc
filesystem:
tigger # ls /proc
1 184 25472 8 8525 kmsg 130 185 25475 82 8526 ksyms 134 186 25497 8484 8593 loadavg 136 187 25498 8485 963 locks 139 2 25499 8488 965 meminfo 143 24924 25500 8489 9654 modules 144 25441 25515 8492 968 mounts 145 25442 25549 8496 97 net 146 25445 25550 8507 99 pci 147 25446 26019 8508 cmdline scsi 148 25449 26662 8510 cpuinfo self 151 25451 26663 8511 devices ...
Get Running Linux, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.