Product SiteDocumentation Site

Chapter 19. The proc File System

19.1. A Virtual File System
19.1.1. Viewing Virtual Files
19.1.2. Changing Virtual Files
19.2. Top-level Files within the proc File System
19.2.1. /proc/buddyinfo
19.2.2. /proc/cmdline
19.2.3. /proc/cpuinfo
19.2.4. /proc/crypto
19.2.5. /proc/devices
19.2.6. /proc/dma
19.2.7. /proc/execdomains
19.2.8. /proc/fb
19.2.9. /proc/filesystems
19.2.10. /proc/interrupts
19.2.11. /proc/iomem
19.2.12. /proc/ioports
19.2.13. /proc/kcore
19.2.14. /proc/kmsg
19.2.15. /proc/loadavg
19.2.16. /proc/locks
19.2.17. /proc/mdstat
19.2.18. /proc/meminfo
19.2.19. /proc/misc
19.2.20. /proc/modules
19.2.21. /proc/mounts
19.2.22. /proc/mtrr
19.2.23. /proc/partitions
19.2.24. /proc/slabinfo
19.2.25. /proc/stat
19.2.26. /proc/swaps
19.2.27. /proc/sysrq-trigger
19.2.28. /proc/uptime
19.2.29. /proc/version
19.3. Directories within /proc/
19.3.1. Process Directories
19.3.2. /proc/bus/
19.3.3. /proc/bus/pci
19.3.4. /proc/driver/
19.3.5. /proc/fs
19.3.6. /proc/irq/
19.3.7. /proc/net/
19.3.8. /proc/scsi/
19.3.9. /proc/sys/
19.3.10. /proc/sysvipc/
19.3.11. /proc/tty/
19.3.12. /proc/PID/
19.4. Using the sysctl Command
19.5. References
The Linux kernel has two primary functions: to control access to physical devices on the computer and to schedule when and how processes interact with these devices. The /proc/ directory (also called the proc file system) contains a hierarchy of special files which represent the current state of the kernel, allowing applications and users to peer into the kernel's view of the system.
The /proc/ directory contains a wealth of information detailing system hardware and any running processes. In addition, some of the files within /proc/ can be manipulated by users and applications to communicate configuration changes to the kernel.

Note

Later versions of the 2.6 kernel have made the /proc/ide/ and /proc/pci/ directories obsolete. The /proc/ide/ file system is now superseded by files in sysfs; to retrieve information on PCI devices, use lspci instead. For more information on sysfs or lspci, refer to their respective man pages.

19.1. A Virtual File System

Linux systems store all data as files. Most users are familiar with the two primary types of files: text and binary. But the /proc/ directory contains another type of file called a virtual file. As such, /proc/ is often referred to as a virtual file system.
Virtual files have unique qualities. Most of them are listed as zero bytes in size, but can still contain a large amount of information when viewed. In addition, most of the time and date stamps on virtual files reflect the current time and date, indicative of the fact they are constantly updated.
Virtual files such as /proc/interrupts, /proc/meminfo, /proc/mounts, and /proc/partitions provide an up-to-the-moment glimpse of the system's hardware. Others, like the /proc/filesystems file and the /proc/sys/ directory provide system configuration information and interfaces.
For organizational purposes, files containing information on a similar topic are grouped into virtual directories and sub-directories. Process directories contain information about each running process on the system.

19.1.1. Viewing Virtual Files

Most files within /proc/ files operate similarly to text files, storing useful system and hardware data in human-readable text format. As such, you can use cat, more, or less to view them. For example, to display information about the system's CPU, run cat /proc/cpuinfo. This will return output 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
Some files in /proc/ contain information that is not human-readable. To retrieve information from such files, use tools such as lspci, apm, free, and top.

Note

Some of the virtual files in the /proc/ directory are readable only by the root user.

19.1.2. Changing Virtual Files

As a general rule, most virtual files within the /proc/ directory are read-only. However, some can be used to adjust settings in the kernel. This is especially true for files in the /proc/sys/ subdirectory.
To change the value of a virtual file, use the following command:
echo value > /proc/file
For example, to change the hostname on the fly, run:
echo www.example.com > /proc/sys/kernel/hostname
Other files act as binary or Boolean switches. Typing cat /proc/sys/net/ipv4/ip_forward returns either a 0 (off or false) or a 1 (on or true). A 0 indicates that the kernel is not forwarding network packets. To turn packet forwarding on, run echo 1 > /proc/sys/net/ipv4/ip_forward.

Tip

Another command used to alter settings in the /proc/sys/ subdirectory is /sbin/sysctl. For more information on this command, refer to Section 19.4, “Using the sysctl Command”
For a listing of some of the kernel configuration files available in the /proc/sys/ subdirectory, refer to Section 19.3.9, “ /proc/sys/.