Penguin
Annotated edit history of proc(5) version 3 showing authors affecting page license. View with all changes included.
Rev Author # Line
1 perry 1 !!NAME
3 PerryLorier 2 proc - process information pseudo-filesystem
1 perry 3
4 !!DESCRIPTION
3 PerryLorier 5 /proc is a pseudo-filesystem which is used as an interface to kernel data structures rather than reading and interpreting /dev/kmem. Most of it is read-only, but some
1 perry 6 files allow kernel variables to be changed.
7
3 PerryLorier 8 The following outline gives a quick tour through the /proc hierarchy.
1 perry 9
3 PerryLorier 10 ;''[[number]'': There is a numerical subdirectory for each running process; the subdirectory is named by the process ID. Each contains the following pseudo-files and directories.
1 perry 11
3 PerryLorier 12 ;''cmdline'': This holds the complete command line for the process, unless the whole process has been swapped out, or unless the process is a zombie. In either of these later cases, there is nothing in this file: i.e. a read on this file will return as having read 0 characters. This file is
1 perry 13 null-terminated, but not newline-terminated.
14
3 PerryLorier 15 ;''cwd'': This is a link to the current working directory of the process. To find out the cwd of process 20, for instance, you can do this:
16 cd /proc/20/cwd; /bin/pwd
1 perry 17
3 PerryLorier 18 ;:Note that the pwd command is often a shell builtin, and might not work properly in this context.
1 perry 19
3 PerryLorier 20 ;''environ'': This file contains the environment for the process. The entries are separated by null characters, and there may be a null character at the end. Thus, to print out the environment of process 1, you would do:
1 perry 21
3 PerryLorier 22 (cat /proc/1/environ; echo) | tr
1 perry 23
3 PerryLorier 24 ;:(For a reason why one should want to do this, see lilo(8).)
1 perry 25
3 PerryLorier 26 ;''exe'': a pointer to the binary which was executed, and appears as a symbolic link. A readlink(2) call on the ''exe'' special file returns under Linux 2.0 and earlier a string in the format:
1 perry 27
3 PerryLorier 28 [[device]:inode
1 perry 29
3 PerryLorier 30 ;:For example, [[0301]:1502 would be inode 1502 on device major 03 (IDE, MFM, etc. drives) minor 01 (first partition on the first drive). Under Linux 2.2 the link contains the actual path name of the command.
1 perry 31
3 PerryLorier 32 ;:Also, the symbolic link can be dereferenced normally - attempting to open /proc/[[number]/exe'' to run another copy of the same process as [[number].
1 perry 33
3 PerryLorier 34 ;:find(1) with the -inum option can be used to locate the file.
1 perry 35
3 PerryLorier 36 ;''fd'': This is a subdirectory containing one entry for each file which the process has open, named by its file descriptor, and which is a symbolic link to the actual file (as the exe entry does). Thus, 0 is standard input, 1 standard output, 2 standard error, etc.
1 perry 37
3 PerryLorier 38 ;:Programs that will take a filename, but will not take the standard input, and which write to a file, but will not send their output to standard output, can be effectively foiled this way, assuming that -i is the flag designating an input file and -o is the flag designating an output file:
1 perry 39
3 PerryLorier 40 foobar -i /proc/self/fd/0 -o /proc/self/fd/1 ...
41 ;:and you have a working filter. Note that this will not work for programs that seek on their files, as the files in the fd directory are not seekable.
1 perry 42
3 PerryLorier 43 ;:/proc/self/fd/N is approximately the same as /dev/fd/N in some UNIX and UNIX-like systems. Most Linux MAKEDEV scripts symbolically link /dev/fd to [[..]/proc/self/fd, in fact.
1 perry 44
3 PerryLorier 45 ;''maps'': A file containing the currently mapped memory regions and their access permissions.
1 perry 46
3 PerryLorier 47 ;:The format is:
48 address perms offset dev inode
49 00000000-0002f000 r-x-- 00000400 03:03 1401
50 0002f000-00032000 rwx-p 0002f400 03:03 1401
51 00032000-0005b000 rwx-p 00000000 00:00 0
52 60000000-60098000 rwx-p 00000400 03:03 215
53 60098000-600c7000 rwx-p 00000000 00:00 0
54 bfffa000-c0000000 rwx-p 00000000 00:00 0
1 perry 55
3 PerryLorier 56 ;:where address is the address space in the process that it occupies, perms is a set of permissions:
1 perry 57
3 PerryLorier 58 r = read
59 w = write
60 x = execute
61 s = shared
62 p = private (copy on write)
63 ;:offset is the offset into the file/whatever, dev is the device (major:minor), and inode is the inode on that device. 0 indicates that no inode is associated with the memory region, as the case would be with bss.
1 perry 64
3 PerryLorier 65 ;:Under Linux 2.2 there is an additional field giving a pathname where applicable.
1 perry 66
3 PerryLorier 67 ;''mem'': This is not the same as the mem (1:1) device, despite the fact that it has the same device numbers. The /dev/mem device is the physical memory before any address translation is done, but the mem file here is the memory of the process that accesses it. This cannot be ''mmap(2)'''ed currently, and will not be until a general ''mmap(2)'' is added to the kernel. (This might have happened by the time you read this.)
1 perry 68
69
3 PerryLorier 70 ;''mmap'': Directory of maps by ''mmap(2)'' which are symbolic links like exe, fd/*, etc. Note that maps includes a superset of this information, so /proc/*/mmap should be considered obsolete.
1 perry 71
3 PerryLorier 72 ;:''/proc/*/mmap'' was removed in Linux kernel version 1.1.40. (It really __was__ obsolete!)
1 perry 73
3 PerryLorier 74 ;''root'': Unix and linux support the idea of a per-process root of the filesystem, set by the ''chroot(2)'' system call. Root points to the file system root, and behaves as exe, fd/*, etc. do.
1 perry 75
3 PerryLorier 76 ;''stat'': Status information about the process. This is used by ''ps(1)''.
1 perry 77
3 PerryLorier 78 ;:The fields, in order, with their proper ''scanf(3)'' format specifiers, are:
1 perry 79
3 PerryLorier 80 |''pid''|%d|The process id.
81 |''comm''|%s| The filename of the executable, in parentheses. This is visible whether or not the executable is swapped out.
82 |''state''|%c| One character from the string
83 |''ppid''|%d| The PID of the parent.
84 |''pgrp''|%d| The process group ID of the process.
85 |''session''|%d| The session ID of the process.
86 |''tty''|%d| The tty the process uses.
87 |''tpgid''|%d| The process group ID of the process which currently owns the tty that the process is connected to.
88 |''flags''|%u|The flags of the process. Currently, every flag has the math bit set, because crt0.s checks for math emulation, so this is not included in the output. This is probably a bug, as not every process is a compiled C program. The math bit should be a decimal 4, and the traced bit is decimal 10.
89 |''minflt''|%u| The number of minor faults the process has made, those which have not required loading a memory page from disk.
90 |''cminflt''|%u| The number of minor faults that the process and its children have made.
91 |''majflt''|%u| The number of major faults the process has made, those which have required loading a memory page from disk.
92 |''cmajflt''|%u| The number of major faults that the process and its children have made.
93 |''utime''|%d| The number of jiffies that this process has been scheduled in user mode.
94 |''stime''|%d| The number of jiffies that this process has been scheduled in kernel mode.
95 |''cutime''|%d| The number of jiffies that this process and its children have been scheduled in user mode.
96 |''cstime''|%d| The number of jiffies that this process and its children have been scheduled in kernel mode.
97 |''counter''|%d| The current maximum size in jiffies of the process's next timeslice, or what is currently left of its current timeslice, if it is the currently running
1 perry 98 process.
3 PerryLorier 99 |''priority''|%d| The standard nice value, plus fifteen. The value is never negative in the kernel.
100 |''timeout''|%u| The time in jiffies of the process's next timeout.
101 |''itrealvalue''|%u|The time (in jiffies) before the next SIGALRM is sent to the process due to an interval timer.
102 |''starttime''|%d| Time the process started in jiffies after system boot.
103 |''vsize''|%u| Virtual memory size
104 |''rss''|%u| Resident Set Size: number of pages the process has in real memory, minus 3 for administrative purposes. This is just the pages which count towards text, data, or stack space. This does not include pages which have not been demand-loaded in, or which are swapped out.
105 |''rlim''|%u Current limit in bytes on the rss of the process (usually 2,147,483,647).
106 |''startcode''|%u| The address above which program text can run.
107 |''endcode''|%u| The address below which program text can run.
108 |''startstack''|%u| The address of the start of the stack.
109 |''kstkesp''|%u|The current value of esp (32-bit stack pointer), as found in the kernel stack page for the process.
110 |''kstkeip''|%u| The current EIP (32-bit instruction pointer).
111 |''signal''|%d| The bitmap of pending signals (usually 0).
112 |''blocked''|%d| The bitmap of blocked signals (usually 0, 2 for shells).
113 |''sigignore''|%d| The bitmap of ignored signals.
114 |''sigcatch''|%d| The bitmap of catched signals.
115 |''wchan''|%u| This is the "channel" in which the process is waiting. It is the address of a system call, and can be looked up in a namelist if you need a textual name. (If you have an up to date /etc/psdatabase, then try ''ps -l'' to see the WCHAN field in action)
1 perry 116
3 PerryLorier 117 !!/proc
118 ;''cpuinfo'': This is a collection of CPU and system architecture dependent items, for each supported architecture a different list. The only two common entries are
119 ''cpu'' which is (guess what) the CPU currently in use and ''BogoMIPS'' a system constant which is calculated during kernel initialization.
120 ;''devices'': Text listing of major numbers and device groups. This can be used by MAKEDEV scripts for consistency with the kernel.
121 ;''dma'': This is a list of the registered ''ISA'' DMA (direct memory access) channels in use.
122 ;''filesystems'': A text listing of the filesystems which were compiled into the kernel. Incidentally, this is used by ''mount(1)'' to cycle through different filesystems when none is specified.
123 ;''interrupts'': This is used to record the number of interrupts per each IRQ on (at least) the i386 architechure. Very easy to read formatting, done in ASCII.
124 ;''ioports'': This is a list of currently registered Input-Output port regions that are in use.
125 ;''kcore'': This file represents the physical memory of the system and is stored in the core file format. With this pseudo-file, and an unstripped kernel (/usr/src/linux/tools/zSystem) binary, GDB can be used to examine the current state of any kernel data structures.
1 perry 126
3 PerryLorier 127 ;:The total length of the file is the size of physical memory (RAM) plus 4KB.
1 perry 128
3 PerryLorier 129 ;''kmsg'': This file can be used instead of the syslog(2) system call to log kernel messages. A process must have superuser privileges to read this file, and only one process should read this file. This file should not be read if a syslog process is running which uses the syslog(2) system call facility to log kernel messages.
1 perry 130
3 PerryLorier 131 ;:Information in this file is retrieved with the dmesg(8) program).
1 perry 132
3 PerryLorier 133 ;''ksyms'': This holds the kernel exported symbol definitions used by the ''modules(X)'' tools to dynamically link and bind loadable modules.
1 perry 134
3 PerryLorier 135 ;''loadavg'': The load average numbers give the number of jobs in the run queue (state R) or waiting for disk I/O (state D) averaged over 1, 5 and 15 minutes. They are the same as the load average numbers given by uptime(1) and other programs.
1 perry 136
3 PerryLorier 137 ;''locks'': This file shows current file locks.
1 perry 138
3 PerryLorier 139 ;''malloc'': This file is only present if CONFIGDEBUGMALLOC was defined during compilation.
1 perry 140
3 PerryLorier 141 ;''meminfo'': This is used by ''free(1)'' to report the amount of free and used memory (both physical and swap) on the system as well as the shared memory and buffers used by the kernel.
1 perry 142
3 PerryLorier 143 ;:It is in the same format as ''free(1)'', except in bytes rather than KB.
1 perry 144
3 PerryLorier 145 ;''modules'': A text list of the modules that have been loaded by the system.
1 perry 146
3 PerryLorier 147 ;''net'': various net pseudo-files, all of which give the status of some part of the networking layer. These files contain ASCII structures, and are therefore readable with cat. However, the standard netstat(8) suite provides much cleaner access to these files.
1 perry 148
3 PerryLorier 149 ;''arp'': This holds an ASCII readable dump of the kernel ARP table used for address resolutions. It will show both dynamically learned and pre-programmed ARP entries. The format is:
1 perry 150
3 PerryLorier 151 IP address HW type Flags HW address
152 10.11.100.129 0x1 0x6 00:20:8A:00:0C:5A
153 10.11.100.5 0x1 0x2 00:C0:EA:00:00:4E
154 44.131.10.6 0x3 0x2 GW4PTS
1 perry 155
3 PerryLorier 156 ;:Where 'IP address' is the IPv4 address of the machine, the 'HW type' is the hardware type of the address from RFC 826. The flags are the internal flags of the ARP structure (as defined in /usr/include/linux/if_arp.h) and the 'HW address' is the physical layer mapping for that IP address if it is known.
1 perry 157
3 PerryLorier 158 ;''dev'': The dev pseudo-file contains network device status information. This gives the number of received and sent packets, the number of errors and collisions and other basic statistics. These are used by the ''ifconfig(8)'' program to report device status. The format is:
1 perry 159
3 PerryLorier 160 Inter-| Receive | Transmit
161 face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
162 lo: 2776770 11307 0 0 0 0 0 0 2776770 11307 0 0 0 0 0 0
163 eth0: 1215645 2751 0 0 0 0 0 0 1782404 4324 0 0 0 427 0 0
164 ppp0: 1622270 5552 1 0 0 0 0 0 354130 5669 0 0 0 0 0 0
165 tap0: 7714 81 0 0 0 0 0 0 7714 81 0 0 0 0 0 0
1 perry 166
3 PerryLorier 167 ;''ipx'': No information.
1 perry 168
169
3 PerryLorier 170 ;''ipx_route'': No information.
1 perry 171
172
3 PerryLorier 173 ;''rarp'': This file uses the same format as the ''arp'' file and contains the current reverse mapping database used to provide ''rarp(8)'' reverse address lookup services. If RARP is not configured into the kernel this file will not be present.
1 perry 174
3 PerryLorier 175 ;''raw'': Holds a dump of the RAW socket table. Much of the information is not of use apart from debugging. The 'sl' value is the kernel hash slot for the socket, the 'local address' is the local address and protocol number pair.
1 perry 176
3 PerryLorier 177 ;''route'': No information, but looks similar to ''route(8)''
1 perry 178
3 PerryLorier 179 ;''snmp'': This file holds the ASCII data needed for the IP, ICMP, TCP and UDP management information bases for an snmp agent. As of writing the TCP mib is incomplete. It is hoped to have it completed by 1.2.0.
1 perry 180
3 PerryLorier 181 ;''tcp'': Holds a dump of the TCP socket table. Much of the information is not of use apart from debugging. The "sl" value is the kernel hash slot for the socket, the "local address" is the local address and port number pair. The "remote address" is the remote address and port number pair (if connected). 'St' is the internal status of the socket. The 'tx_queue' and 'rx_queue' are the outgoing and incoming data queue in terms of kernel memory usage. The "tr", "tm->when", and "rexmits" fields hold internal information of the kernel socket state and are only useful for debugging. The uid field holds the creator euid of the socket.
1 perry 182
3 PerryLorier 183 ;''udp'': Holds a dump of the UDP socket table. Much of the information is not of use apart from debugging. The "sl" value is the kernel hash slot for the socket, the "local address" is the local address and port number pair. The "remote address" is the remote address and port number pair (if connected). "St" is the internal status of the socket. The "tx_queue" and "rx_queue" are the outgoing and incoming data queue in terms of kernel memory usage. The "tr", "tm->when", and "rexmits" fields are not used by UDP. The uid field holds the creator euid of the socket. The format is:
1 perry 184
3 PerryLorier 185 sl local_address rem_address st tx_queue rx_queue tr rexmits tm->when uid
186 1: 01642C89:0201 0C642C89:03FF 01 00000000:00000001 01:000071BA 00000000 0
187 1: 00000000:0801 00000000:0000 0A 00000000:00000000 00:00000000 6F000100 0
188 1: 00000000:0201 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0
1 perry 189
3 PerryLorier 190 ;''unix'': Lists the UNIX domain sockets present within the system and their status. The format is:
1 perry 191
3 PerryLorier 192 Num !RefCount Protocol Flags Type St Path
193 0: 00000002 00000000 00000000 0001 03
194 1: 00000001 00000000 00010000 0001 01 /dev/printer
1 perry 195
196
3 PerryLorier 197 ;:Where 'Num' is the kernel table slot number, '!RefCount' is the number of users of the socket, 'Protocol' is currently always 0, 'Flags' represent the internal kernel flags holding the status of the socket. Type is always '1' currently (Unix domain datagram sockets are not yet supported in the kernel). 'St' is the internal state of the
198 socket and Path is the bound path (if any) of the socket.
1 perry 199
3 PerryLorier 200 ;''pci'': This is a listing of all PCI devices found during kernel initialization and their configuration.
1 perry 201
3 PerryLorier 202 ;''scsi'': A directory with the scsi midlevel pseudo-file and various SCSI lowlevel driver directories, which contain a file for each SCSI host in this system, all of which give the status of some part of the SCSI IO subsystem. These files contain ASCII structures, and are therefore readable with cat.
1 perry 203
3 PerryLorier 204 ;:You can also write to some of the files to reconfigure the subsystem or switch certain features on or off.
1 perry 205
3 PerryLorier 206 ;''scsi'': This is a listing of all SCSI devices known to the kernel. The listing is similar to the one seen during bootup. scsi currently supports only the ''add-single-device'' command which allows root to add a hotplugged device to the list of known devices.
1 perry 207
3 PerryLorier 208 ;:An
209 echo 'scsi add-single-device 1 0 5 0' >/proc/scsi/scsi
210 ;:will cause host scsi1 to scan on SCSI channel 0 for a device on ID 5 LUN 0. If there is already a device known on this address or the address is invalid an error will be returned.
1 perry 211
3 PerryLorier 212 ;''drivername'': ''drivername'' can currently be: NCR53c7xx, aha152x, aha1542, aha1740, aic7xxx, buslogic, eata_dma, eata_pio, fdomain, in2000, pas16, qlogic, scsi_debug, seagate, t128, u15-24f, ultrastore or wd7000. These directories show up for all drivers which registered at least one SCSI HBA. Every directory contains one file per registered host. Every host-file is named after the number the host got assigned during initilization.
1 perry 213
3 PerryLorier 214 ;:Reading these files will usually show driver and host configuration, statistics etc.
1 perry 215
3 PerryLorier 216 Writing to these files allows different things on different hosts. For example with the ''latency'' and ''nolatency'' commands root can switch on and off command
217 latency measurement code in the eata_dma driver. With the ''lockup'' and ''unlock'' commands root can control bus lockups simulated by the scsi_debug driver.
1 perry 218
3 PerryLorier 219 ;''self'': This directory refers to the process accessing the /proc filesystem, and is identical to the /proc directory named by the process ID of the same process.
1 perry 220
3 PerryLorier 221 ;''stat'': kernel/system statistics
1 perry 222
3 PerryLorier 223 ''cpu 3357 0 4313 1362393''
1 perry 224
3 PerryLorier 225 ;:The number of jiffies (1/100ths of a second) that the system spent in user mode, user mode with low priority (nice), system mode, and the idle task, respectively. The last value should be 100 times the second entry in the uptime pseudo-file.
1 perry 226
227
3 PerryLorier 228 ''disk 0 0 0 0''
1 perry 229
3 PerryLorier 230 ;:The four disk entries are not implemented at this time. I'm not even sure what this should be, since kernel statistics on other machines usually track both transfer rate and I/Os per second and this only allows for one field per drive.
1 perry 231
3 PerryLorier 232 ''page 5741 1808''
1 perry 233
3 PerryLorier 234 ;:The number of pages the system paged in and the number that were paged out (from disk).
1 perry 235
3 PerryLorier 236 ''swap 1 0''
1 perry 237
3 PerryLorier 238 ;:The number of swap pages that have been brought in and out.
1 perry 239
3 PerryLorier 240 ''intr 1462898''
1 perry 241
3 PerryLorier 242 ;:The number of interrupts received from the system boot.
1 perry 243
3 PerryLorier 244 ''ctxt 115315''
1 perry 245
3 PerryLorier 246 ;:The number of context switches that the system underwent.
1 perry 247
3 PerryLorier 248 ''btime 769041601''
1 perry 249
3 PerryLorier 250 ;:boot time, in seconds since the epoch (January 1, 1970).
1 perry 251
252
3 PerryLorier 253 ;''sys'': This directory (present since 1.3.57) contains a number of files and subdirectories corresponding to kernel variables. These variables can be read and sometimes modified using the ''proc'' file system, and using the sysctl(2) system call. Presently, there are subdirectories ''kernel'', ''net'', ''vm'' that each contain more
1 perry 254 files and subdirectories.
255
3 PerryLorier 256 ;''kernel'': This contains files ''domainname'', ''file-max'', ''file-nr'', ''hostname'', ''inode-max'', ''inode-nr'', ''osrelease'', ''ostype'',
257 ''panic'', ''real-root-dev'', ''securelevel'', ''version'', with function fairly clear from the name.
1 perry 258
3 PerryLorier 259 ;:The (read-only) file ''file-nr'' gives the number of files presently opened.
1 perry 260
3 PerryLorier 261 ;:The file ''file-max'' gives the maximum number of open files the kernel is willing to handle. If 1024 is not enough for you, try
262 echo 4096 >file-max
263 ;:Similarly, the files ''inode-nr'' and ''inode-max'' indicate the present and the maximum number of inodes.
1 perry 264
3 PerryLorier 265 ;:The files ''ostype'', ''osrelease'', ''version'' give substrings of ''/proc/version''.
1 perry 266
3 PerryLorier 267 ;:The file ''panic'' gives r/w access to the kernel variable ''panic_timeout''. If this is zero, the kernel will loop on a panic; if nonzero it indicates that the
268 kernel should autoreboot after this number of seconds.
1 perry 269
3 PerryLorier 270 ;:The file ''securelevel'' seems rather meaningless at present - root is just too powerful.
1 perry 271
272
3 PerryLorier 273 ;''uptime'': This file contains two numbers: the uptime of the system (seconds), and the amount of time spent in idle process (seconds).
1 perry 274
3 PerryLorier 275 ;''version'': This strings identifies the kernel version that is currently running. For instance:
276 Linux version 1.0.9 (quinlan@phaze) #1 Sat May 14 01:51:54 EDT 1994
1 perry 277
278 !!SEE ALSO
3 PerryLorier 279 cat(1), find(1), free(1), mount(1), ps(1), tr(1), uptime(1), chroot(2), mmap(2), readlink(2), syslog(2), slabinfo(5), hier(7), arp(8), dmesg(8), netstat(8), ifconfig(8), procinfo(8), route(8), and much more
1 perry 280
281 !!CONFORMS TO
3 PerryLorier 282 This roughly conforms to a Linux 1.3.11 kernel. Please update this as necessary!
1 perry 283
3 PerryLorier 284 Last updated for Linux 1.3.11.
1 perry 285
286 !!CAVEATS
3 PerryLorier 287 Note that many strings (i.e., the environment and command line) are in the internal format, with sub-fields terminated by NUL bytes, so you may find that things are more readable if you use ''od -c'' or ''tr "\000" "\n"'' to read them.
1 perry 288
3 PerryLorier 289 This manual page is incomplete, possibly inaccurate, and is the kind of thing that needs to be updated very often.
1 perry 290
291 !!BUGS
3 PerryLorier 292 The ''/proc'' file system may introduce security holes into processes running with chroot(2). For example, if ''/proc'' is mounted in the __chroot__ hierarchy, a
293 chdir(2) to ''/proc/1/root'' will return to the original root of the file system. This may be considered a feature instead of a bug, since Linux does not yet support
1 perry 294 the fchroot(2) call.
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.

PHP Warning

lib/blame.php:177: Warning: Invalid argument supplied for foreach() (...repeated 8 times)