An Overview of the Proc Filesystem LG #46

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:

  1. A brief explanation of what it is
  2. What /proc can be used for (or sometimes not to be used for)
  3. A map of /proc as of the 2.2 Kernel on the i686 architecture

What is /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.

What /proc can do for an Administrator

The /proc fs can be used for system related tasks such as:

  • Viewing Statistical Information
  • Finding out Hardware Information
  • Modifying Runtime Parameters
  • Viewing and Modifying Network and Host Parameters
  • Memory and Performance Information

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 = Different Capabilities

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.

The Obligatory Warning

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.

READ  News Bytes LG #53

A Map of /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

Numbered Directories

The number directories are running process information by PID.

Results May Vary

Again, keep in mind that the capabilities of /proc and it’s contents do vary version to version, otherwise, happy exploring.

For More Information

Below is a short list of sites with in depth information (LDP aside of course) about /proc contributed by readers:

  • The /proc File System
  • The C10k problem
Copyright © 1999, Jay Fink
Published in Issue 46 of Linux Gazette, October 1999

indexnew-1118409 homenew-1151523 back2-9927604 fwd-7457813