11.5 The /proc File System
The /proc file system is a pseudo file system in
which the kernel reserves important information in the form of virtual
files. For example, display the CPU type with this command:
tux@mercury:~> cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 15
model : 4
model name : Intel(R) Pentium(R) 4 CPU 3.40GHz
stepping : 3
cpu MHz : 2800.000
cache size : 2048 KB
physical id : 0
[...]
Query the allocation and use of interrupts with the following command:
tux@mercury:~> cat /proc/interrupts
CPU0
0: 3577519 XT-PIC timer
1: 130 XT-PIC i8042
2: 0 XT-PIC cascade
5: 564535 XT-PIC Intel 82801DB-ICH4
7: 1 XT-PIC parport0
8: 2 XT-PIC rtc
9: 1 XT-PIC acpi, uhci_hcd:usb1, ehci_hcd:usb4
10: 0 XT-PIC uhci_hcd:usb3
11: 71772 XT-PIC uhci_hcd:usb2, eth0
12: 101150 XT-PIC i8042
14: 33146 XT-PIC ide0
15: 149202 XT-PIC ide1
NMI: 0
LOC: 0
ERR: 0
MIS: 0
Some of the important files and their contents are:
- /proc/devices
-
Available devices
- /proc/modules
-
Kernel modules loaded
- /proc/cmdline
-
Kernel command line
- /proc/meminfo
-
Detailed information about memory usage
- /proc/config.gz
-
gzip-compressed configuration file of the kernel
currently running
Further information is available in the text file
/usr/src/linux/Documentation/filesystems/proc.txt
(this file is available when the package
kernel-source is installed). Find information
about processes currently running in the
/proc/NNN directories,
where NNN is the process ID (PID) of the
relevant process. Every process can find its own characteristics in
/proc/self/:
tux@mercury:~> ls -l /proc/self
lrwxrwxrwx 1 root root 64 2007-07-16 13:03 /proc/self -> 5356
tux@mercury:~> ls -l /proc/self/
total 0
dr-xr-xr-x 2 tux users 0 2007-07-16 17:04 attr
-r-------- 1 tux users 0 2007-07-16 17:04 auxv
-r--r--r-- 1 tux users 0 2007-07-16 17:04 cmdline
lrwxrwxrwx 1 tux users 0 2007-07-16 17:04 cwd -> /home/tux
-r-------- 1 tux users 0 2007-07-16 17:04 environ
lrwxrwxrwx 1 tux users 0 2007-07-16 17:04 exe -> /bin/ls
dr-x------ 2 tux users 0 2007-07-16 17:04 fd
-rw-r--r-- 1 tux users 0 2007-07-16 17:04 loginuid
-r--r--r-- 1 tux users 0 2007-07-16 17:04 maps
-rw------- 1 tux users 0 2007-07-16 17:04 mem
-r--r--r-- 1 tux users 0 2007-07-16 17:04 mounts
-rw-r--r-- 1 tux users 0 2007-07-16 17:04 oom_adj
-r--r--r-- 1 tux users 0 2007-07-16 17:04 oom_score
lrwxrwxrwx 1 tux users 0 2007-07-16 17:04 root -> /
-rw------- 1 tux users 0 2007-07-16 17:04 seccomp
-r--r--r-- 1 tux users 0 2007-07-16 17:04 smaps
-r--r--r-- 1 tux users 0 2007-07-16 17:04 stat
[...]
dr-xr-xr-x 3 tux users 0 2007-07-16 17:04 task
-r--r--r-- 1 tux users 0 2007-07-16 17:04 wchan
The address assignment of executables and libraries is contained in the
maps file:
tux@mercury:~> cat /proc/self/maps
08048000-0804c000 r-xp 00000000 03:03 17753 /bin/cat
0804c000-0804d000 rw-p 00004000 03:03 17753 /bin/cat
0804d000-0806e000 rw-p 0804d000 00:00 0 [heap]
b7d27000-b7d5a000 r--p 00000000 03:03 11867 /usr/lib/locale/en_GB.utf8/
b7d5a000-b7e32000 r--p 00000000 03:03 11868 /usr/lib/locale/en_GB.utf8/
b7e32000-b7e33000 rw-p b7e32000 00:00 0
b7e33000-b7f45000 r-xp 00000000 03:03 8837 /lib/libc-2.3.6.so
b7f45000-b7f46000 r--p 00112000 03:03 8837 /lib/libc-2.3.6.so
b7f46000-b7f48000 rw-p 00113000 03:03 8837 /lib/libc-2.3.6.so
b7f48000-b7f4c000 rw-p b7f48000 00:00 0
b7f52000-b7f53000 r--p 00000000 03:03 11842 /usr/lib/locale/en_GB.utf8/
[...]
b7f5b000-b7f61000 r--s 00000000 03:03 9109 /usr/lib/gconv/gconv-module
b7f61000-b7f62000 r--p 00000000 03:03 9720 /usr/lib/locale/en_GB.utf8/
b7f62000-b7f76000 r-xp 00000000 03:03 8828 /lib/ld-2.3.6.so
b7f76000-b7f78000 rw-p 00013000 03:03 8828 /lib/ld-2.3.6.so
bfd61000-bfd76000 rw-p bfd61000 00:00 0 [stack]
ffffe000-fffff000 ---p 00000000 00:00 0 [vdso]
11.5.1
procinfo
Important information from the /proc file system is
summarized by the command procinfo:
tux@mercury:~> procinfo
Linux 2.6.18.8-0.5-default (geeko@buildhost) (gcc 4.1.2 20061115) #1 2CPU
Memory: Total Used Free Shared Buffers
Mem: 2060604 2011264 49340 0 200664
Swap: 2104472 112 2104360
Bootup: Tue Jul 10 10:29:15 2007 Load average: 0.86 1.10 1.11 3/118 21547
user : 2:43:13.78 0.8% page in : 71099181 disk 1: 2827023r 968
nice : 1d 22:21:27.87 14.7% page out: 690734737
system: 13:39:57.57 4.3% page act: 138388345
IOwait: 18:02:18.59 5.7% page dea: 29639529
hw irq: 0:03:39.44 0.0% page flt: 9539791626
sw irq: 1:15:35.25 0.4% swap in : 69
idle : 9d 16:07:56.79 73.8% swap out: 209
uptime: 6d 13:07:11.14 context : 542720687
irq 0: 141399308 timer irq 14: 5074312 ide0
irq 1: 73784 i8042 irq 50: 1938076 uhci_hcd:usb1, ehci_
irq 4: 2 irq 58: 0 uhci_hcd:usb2
irq 6: 5 floppy [2] irq 66: 872711 uhci_hcd:usb3, HDA I
irq 7: 2 irq 74: 15 uhci_hcd:usb4
irq 8: 0 rtc irq 82: 178717720 0 PCI-MSI e
irq 9: 0 acpi irq169: 44352794 nvidia
irq 12: 3 irq233: 8209068 0 PCI-MSI l
To see all the information, use the parameter -a. The
parameter -nN produces updates of the information every
N seconds. In this case, terminate the
program by pressing Q.
By default, the cumulative values are displayed. The parameter
-d produces the differential values. procinfo
-dn5 displays the values that have changed in the last five
seconds: