
Chapter 2.
The /proc File System
The Linux kernel’s primary functions are to control access to physical devices on the computer and to
schedule when and how processes interact with these devices. The /proc directory contains hierarchy
of virtual folders and files which represent the current state of the kernel. Viewing files within /proc
allows the user to peer into the kernel’s view of the system. In addition, the user can use these virtual
files to communicate configuration changes to the kernel.
2.1. A Virtual File System
In Linux, everything is stored as a file. Most users are familiar with the two primary types of files, text
and binary. However, the /proc directory contains files that are not part of any file system associated
with any physical storage device connected to your system. Instead, the virtual files in /proc are part
of a virtual file system.
The virtual files in /proc have unique qualities. Most of them are 0 bytes in size. Yet when the file
is viewed, it can contain quite a bit of information. In addition, most of their time and date settings
reflect the current time and date, meaning that they are constantly changing.
Both applications and system administrators can use /proc as a method of accessing information
about the state of the kernel, the attributes of the machine, the state of individual processes, and so on.
Most of the files in the directory, such as interrupts, meminfo, mounts, and partitions, provide
an up-to-the-moment glimpse of a system’s physical environment. Others, like file systems and
the /proc/sys/ directory provide software configuration information.
To make things easier, files that contain information covering a similar topic are grouped into virtual
directories and sub-directories, such as /proc/ide/ for all physical IDE devices.
2.1.1. Viewing Virtual Files
By using cat, more, or less commands on the files within /proc, you can immediately access an
enormous amount of information about the system. For example, if you want to see what sort of CPU
your computer has, type cat cpuinfo and you will see something similar to the following:
processor : 0
vendor_id : AuthenticAMD
cpu family : 5
model : 9
model name : AMD-K6(tm) 3D+ Processor
stepping : 1
cpu MHz : 400.919
cache size : 256 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 1
wp : yes
flags : fpu vme de pse tsc msr mce cx8 pge mmx syscall 3dnow k6_mtrr
bogomips : 799.53
Commenti su questo manuale