Pick a Free OS

Exploring /proc

The most striking factor about the /proc file system is the fact that the

file system doesn't exist on any particular media. The /proc File System

is a pseudo file system residing in the virtual memory and

maintains highly dynamic data on the state of your operating system. Most

of the information in the /proc file system is updated to match the

current state of the operating system. The contents of the /proc file

system can be read by anyone who has the requisite permissions. However,

certain parts of the /proc file system can be read only by the owner of

the process and of course root. The contents of the /proc filesystem are

used by many utilities which grab the data from the particular /proc

directory and display it.

Under Linux, we have utilities like lscpi, scanpci and pnpdump which help

us detect the various PCI, ISA hardware chipsets and help us make the best

choices as far as the io, dma and irq values are concerned. Similarly by

looking at the values of the various parameters in the /proc file system,

one can determine a lot about the current state of the kernel and the

processes under way. For example, we have the dmesg command.

bash# dmesg

Dmesg helps us determine the devices that have been detected and

initialized by the Linux kernel. We have utilities like "ps" and "top"

which give an accurate snapshot about the status of the processes running

on the machine and a list of awake and sleeping processes currently

running on the machine. Have you ever wondered where exactly the

information dished out to you by the "ps" and the "top" process comes

from? The information for these processes come from the /proc file system

which is updated on the fly as changes take place in the processes.

Lets take a look at a snapshot of the directory listing of the root (/)

directory of a Linux machine.

drwxr-xr-x 14 root root 291 Oct 25 18:47 opt

dr-xr-xr-x 86 root root 0 Nov 30 2000 proc <--

drwx--x--x 16 root root 841 Nov 20 00:10 root

drwxr-xr-x 5 root root 4627 Oct 15 11:42 sbin

Since the /proc file system is a virtual file system and resides in

memory, a new /proc file system is created every time your Linux machine

reboots. Take a look at the snapshot of the root directory shown above.

The size of the proc directory is 0 and the last time of modification is

the current date.