One of the more interesting aspects of certain flavors of UN*X (Linux among them) is the /proc
filesystem. This "virtual" filesystem has several key features which are interesting, useful and helpful. It can also be dangerous and disastrous. This column will approach the /proc
filesystem in three areas:
/proc
can be used for (or sometimes not to be used for)/proc
as of the 2.2 Kernel on the i686 architecture/proc
?The /proc
filesystem is a direct reflection of the system kept in memory and represented in a hierarchal manner. The effort of the /proc
filesystem is to provide an easy way to view kernel and information about currently running processes. As a result, some commands (ps for example) read /proc
directly to get information about the state of the system. The premise behind /proc
is to provide such information in a readable manner instead of having to invoke difficult to understand system calls.
/proc
can do for an AdministratorThe /proc
fs can be used for system related tasks such as:
There are some things to take note of, most of those tasks can be done with tools that either peruse /proc
or query the kernel directly.
Different kernels can allow for different changes and information that is presented within /proc
. Some, all, or totally different layouts and capabilities may exist depending on your machine's kernel implementation.
Since there is no one place that documents exactly what you can and cannot do with /proc
(again because of distro's) there is no fool-proofing it other than only root may actually descend /proc
and monkey with the files therein. I have found the easiest approach to be a sort of hacker method - backup your kernel and apply common sense when making alterations within the /proc
fs.
A prime example of tuning applications via /proc
can be found at the The C10k problem document at Dan Kegel's Web Hostel.
/proc
Following is a table with brief descriptions of files and directories in /proc
with the 2.2 kernel on a Linux i686 architecture.
loadavg |
Average of system load for the last 1, 5 and 15 minutes |
uptime |
Time in seconds since boot-up and total time used by processes |
meminfo |
The number of total, used and free bytes of memory and swap area(s) |
kmsg |
Kernel messages that have yet to be read in by the kernel |
version |
Current rev of the kernel and/or distribution (read from linux_banner |
cpuinfo |
Recognized processor parameters |
pci |
Current occupation of pci slots. |
self/ |
Information about processes currently accessing /proc |
net/ |
Descriptions about the network layer(s) |
scsi/ |
Contains files with information on individual scsi devices |
malloc |
Monitoring provisions for kmalloc and kfree operations |
kcore |
A core dump for the kernel (memory snapshot) |
modules |
Information regarding single loaded modules |
stat |
General Linux Statistics |
devices |
Information about kernel registered devices on the system |
interrupts |
Interrupt assignment information |
filesystems |
Existing filesystem implementations |
ksyms |
Symbols exported by the kernel |
dma |
Occupied DMA channels |
ioports |
Currently occupied IO ports |
smp |
Individual information about CPU's if SMP is enabled |
cmdline |
Command line parameters passed to the kernel at boot time |
sys/ |
Important kernel and network information |
mtab |
Currently mounted filesystems |
md |
Multiple device driver information (if enabled) |
rc |
Enhanced real time clock (if enabled) |
locks |
Currently locked files |
The number directories are running process information by PID.
Again, keep in mind that the capabilities of /proc and it's contents do vary version to version, otherwise, happy exploring.
Below is a short list of sites with in depth information (LDP aside of course) about /proc contributed by readers: