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 occupies 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 a
directory or view file contents in the
filesystem, the kernel dynamically generates the contents you want to
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
ls /proc1 1618 17613 27191 27317 2859 8929 kcore_elf rtc 11120 1621 1795 27192 27320 2860 9 kmsg scsi 11121 1649 1796 27204 27324 28746 bus ksyms self 11153 1657 1798 27205 27326 28747 cmdline loadavg slabinfo 15039 1664 1799 27221 27374 28754 config.gz locks stat 1512 1681 1800 27229 27377 29877 cpuinfo lvm swaps 1530 1689 2 27287 27379 29878 devices mdstat sys ...