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.
Within the /proc/ directory, one can find a wealth of information detailing the system hardware and any processes currently running. In addition, some of the files within the /proc/ directory tree can be manipulated by users and applications to communicate configuration changes to the kernel.
Under Linux, all data are stored 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. It is for this reason that /proc/ is often referred to as a virtual file system. These virtual files have unique qualities. Most of them are listed as zero bytes in size and yet when one is viewed, it can contain a large amount of information. In addition, most of the time and date settings on virtual files reflect the current time and date, indicative of the fact they are constantly updated.
I have listed some of them with examples:
This file is used to display the type of CPU a computer has and other processor related parameters:
- processor — Provides each processor with an identifying number. On systems that have one processor, only a 0 is present.
- cpu family — Authoritatively identifies the type of processor in the system. For an Intel-based system, place the number in front of “86” to determine the value. This is particularly helpful for those attempting to identify the architecture of an older system such as a 586, 486, or 386. Because some RPM packages are compiled for each of these particular architectures, this value also helps users determine which packages to install.
- model name — Displays the common name of the processor, including its project name.
- cpu MHz — Shows the precise speed in megahertz for the processor to the thousandths decimal place.
- cache size — Displays the amount of level 2 memory cache available to the processor.
- siblings — Displays the number of sibling CPUs on the same physical CPU for architectures which use hyper-threading.
- flags — Defines a number of different qualities about the processor, such as the presence of a floating point unit (FPU) and the ability to process MMX instructions.
This file is used primarily for diagnosing memory fragmentation issues. Using the buddy algorithm, each column represents the number of pages of a certain order (a certain size) that are available at any given time. For example, for zone DMA (direct memory access), there are 90 of 2^(0*PAGE_SIZE) chunks of memory. Similarly, there are 6 of 2^(1*PAGE_SIZE) chunks, and 2 of 2^(2*PAGE_SIZE) chunks of memory available.
The DMA row references the first 16 MB on a system, the HighMem row references all memory greater than 4 GB on a system, and the Normal row references all memory in between.
This file lists all installed cryptographic ciphers used by the Linux kernel, including additional details for each. A sample /proc/crypto file looks like the following:
This file displays the various character and block devices currently configured (not including devices whose modules are not loaded). Below is a sample output from this file:
The output from /proc/devices includes the major number and name of the device, and is broken into two major sections: Character devices and Block devices.
This file displays a list of the file system types currently supported by the kernel. Sample output from a generic /proc/filesystems file looks similar to the following:
The first column signifies whether the file system is mounted on a block device. Those beginning with nodev are not mounted on a device. The second column lists the names of the file systems supported.
The mount command cycles through the file systems listed here when one is not specified as an argument.
This file provides a look at the load average in regard to both the CPU and IO over time, as well as additional data used by uptime and other commands. A sample /proc/loadavg file looks similar to the following:
The first three columns measure CPU and IO utilization of the last one, five, and 10 minute periods. The fourth column shows the number of currently running processes and the total number of processes. The last column displays the last process ID used.
This file displays a list of all modules loaded into the kernel. Its contents vary based on the configuration and use of your system, but it should be organized in a similar manner to this sample /proc/modules file output:
- The first column contains the name of the module.
- The second column refers to the memory size of the module, in bytes.
- The third column lists how many instances of the module are currently loaded. A value of zero represents an unloaded module.
- The fourth column states if the module depends upon another module to be present in order to function, and lists those other modules.
- The fifth column lists what load state the module is in: Live, Loading, or Unloading are the only possible values.
- The sixth column lists the current kernel memory offset for the loaded module. This information can be useful for debugging purposes, or for profiling tools such as oprofile.
This file provides a list of all mounts in use by the system:
The output found here is similar to the contents of /etc/mtab, except that /proc/mounts is more up-to-date.
The first column specifies the device that is mounted, the second column reveals the mount point, and the third column tells the file system type, and the fourth column tells you if it is mounted read-only (ro) or read-write (rw). The fifth and sixth columns are dummy values designed to match the format used in /etc/mtab.
This file contains partition block allocation information. A sampling of this file from a basic system looks similar to the following:
Most of the information here is of little importance to the user, except for the following columns:
- major — The major number of the device with this partition. The major number in the /proc/partitions, (3), corresponds with the block device ide0, in /proc/devices.
- minor — The minor number of the device with this partition. This serves to separate the partitions into different physical devices and relates to the number at the end of the name of the partition.
- #blocks — Lists the number of physical disk blocks contained in a particular partition.
- name — The name of the partition.
When viewing different virtual files in the /proc/ file system, some of the information is easily understandable while some is not human-readable. This is why utilities like lspci, apm, free, top, etc exist to pull data from virtual files and display it in a useful way.