The following outline gives a quick tour through the /proc hierarchy.
cd /proc/20/cwd; /bin/pwd
Note that the pwd command is often a shell builtin, and might not work properly. In bash, you may use pwd -P.
(cat /proc/1/environ; echo) | tr "\000" "\n"
(For a reason why one should want to do this, see lilo(8).)
Under Linux 2.0 and earlier exe is a pointer to the binary which was executed, and appears as a symbolic link. A readlink(2) call on the exe special file under Linux 2.0 returns a string in the format:
[device]:inode
For example, [0301]:1502 would be inode 1502 on device major 03 (IDE, MFM, etc. drives) minor 01 (first partition on the first drive).
find(1) with the -inum option can be used to locate the file.
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:
foobar -i /proc/self/fd/0 -o /proc/self/fd/1 ...
/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.
The format is:
address perms offset dev inode pathname 08048000-08056000 r-xp 00000000 03:0c 64593 /usr/sbin/gpm 08056000-08058000 rw-p 0000d000 03:0c 64593 /usr/sbin/gpm 08058000-0805b000 rwxp 00000000 00:00 0 40000000-40013000 r-xp 00000000 03:0c 4165 /lib/ld-2.2.4.so 40013000-40015000 rw-p 00012000 03:0c 4165 /lib/ld-2.2.4.so 4001f000-40135000 r-xp 00000000 03:0c 45494 /lib/libc-2.2.4.so 40135000-4013e000 rw-p 00115000 03:0c 45494 /lib/libc-2.2.4.so 4013e000-40142000 rw-p 00000000 00:00 0 bffff000-c0000000 rwxp 00000000 00:00 0
where address is the address space in the process that it occupies, perms is a set of permissions:
r = read w = write x = execute s = shared p = private (copy on write)
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.
Under Linux 2.0 there is no field giving pathname.
The fields, in order, with their proper scanf(3) format specifiers, are:
cache buffer size in KB capacity number of sectors driver driver version geometry physical and logical geometry identify in hexidecimal media media type model manufacturer's model number settings drive settings smart_thresholds in hexidecimal smart_values in hexidecimal
The hdparm(8) utility provides access to this information in a friendly format.
The total length of the file is the size of physical memory (RAM) plus 4KB.
Information in this file is retrieved with the dmesg(8) program.
It is in the same format as free(1), except in bytes rather than KB.
IP address HW type Flags HW address Mask Device 192.168.0.50 0x1 0x2 00:50:BF:25:68:F3 * eth0 192.168.0.250 0x1 0xc 00:00:00:00:00:00 * eth0
Here 'IP address' is the IPv4 address of the machine and 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.
Inter-| Receive | Transmit
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
lo: 2776770 11307 0 0 0 0 0 0 2776770 11307 0 0 0 0 0 0
eth0: 1215645 2751 0 0 0 0 0 0 1782404 4324 0 0 0 427 0 0
ppp0: 1622270 5552 1 0 0 0 0 0 354130 5669 0 0 0 0 0 0
tap0: 7714 81 0 0 0 0 0 0 7714 81 0 0 0 0 0 0
sl local_address rem_address st tx_queue rx_queue tr rexmits tm->when uid 1: 01642C89:0201 0C642C89:03FF 01 00000000:00000001 01:000071BA 00000000 0 1: 00000000:0801 00000000:0000 0A 00000000:00000000 00:00000000 6F000100 0 1: 00000000:0201 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0
Num RefCount Protocol Flags Type St Path 0: 00000002 00000000 00000000 0001 03 1: 00000001 00000000 00010000 0001 01 /dev/printer
Here '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. Currently, type is always '1' (Unix domain datagram sockets are not yet supported in the kernel). 'St' is the internal state of the socket and Path is the bound path (if any) of the socket.
You can also write to some of the files to reconfigure the subsystem or switch certain features on or off.
An echo 'scsi add-single-device 1 0 5 0' > /proc/scsi/scsi 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.
Reading these files will usually show driver and host configuration, statistics etc.
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 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.
cache-name num-active-objs total-objs object-size num-active-slabs total-slabs num-pages-per-slabSee slabinfo(5) for details.
Documentation for the files in /proc/sys/binfmt_misc is in the kernel sources in Documentation/binfmt_misc.txt.
The file dentry-state contains six numbers, nr_dentry, nr_unused, age_limit (age in seconds), want_pages (pages requested by system) and two dummy values. nr_dentry seems to be 0 all the time. nr_unused seems to be the number of unused dentries. age_limit is the age in seconds after which dcache entries can be reclaimed when memory is short and want_pages is nonzero when the kernel has called shrink_dcache_pages() and the dcache isn't pruned yet.
The file dir-notify-enable can be used to disable or enable the dnotify interface described in fcntl(2) on a system-wide basis. A value of 0 in this file disables the interface, and a value of 1 enables it.
The file dquot-max shows the maximum number of cached disk quota entries. On some (2.4) systems, it is not present. If the number of free cached disk quotas is very low and you have some awesome number of simultaneous system users, you might want to raise the limit.
The file dquot-nr shows the number of allocated disk quota entries and the number of free disk quota entries.
The file
file-max
is a system-wide limit on the number of open files for all processes.
(See also
setrlimit(2),
which can be used by a process to set the per-process limit,
RLIMIT_NOFILE,
on the number of files it may open.)
If you get lots
of error messages about running out of file handles,
try increasing this value:
echo 100000 > /proc/sys/fs/file-max
The kernel constant NR_OPEN imposes an upper limit on the value that may be placed in file-max.
If you increase file-max, be sure to increase inode-max to 3-4 times the new value of file-max, or you will run out of inodes.
The (read-only) file file-nr gives the number of files presently opened. It contains three numbers: The number of allocated file handles, the number of free file handles and the maximum number of file handles. The kernel allocates file handles dynamically, but it doesn't free them again. If the number of allocated files is close to the maximum, you should consider increasing the maximum. When the number of free file handles is large, you've encountered a peak in your usage of file handles and you probably don't need to increase the maximum.
The file inode-max contains the maximum number of in-memory inodes. On some (2.4) systems, it may not be present. This value should be 3-4 times larger than the value in file-max, since stdin, stdout and network sockets also need an inode to handle them. When you regularly run out of inodes, you need to increase this value.
The file inode-nr contains the first two values from inode-state.
The file inode-state contains seven numbers: nr_inodes, nr_free_inodes, preshrink and four dummy values. nr_inodes is the number of inodes the system has allocated. This can be slightly more than inode-max because Linux allocates them one pageful at a time. nr_free_inodes represents the number of free inodes. preshrink is nonzero when the nr_inodes > inode-max and the system needs to prune the inode list instead of allocating more.
The file lease-break-time specifies the grace period that the kernel grants to a process holding a file lease (fcntl(2)) after it has sent a signal to that process notifying it that another process is waiting to open the file. If the lease holder does not remove or downgrade the lease within this grace period, the kernel forcibly breaks the lease.
The file leases-enable can be used to enable or disable file leases (fcntl(2)) on a system-wide basis. If this file contains the value 0, leases are disabled. A non-zero value enables leases.
The files overflowgid and overflowuid allow you to change the value of the fixed UID and GID. The default is 65534. Some filesystems only support 16-bit UIDs and GIDs, although in Linux UIDs and GIDs are 32 bits. When one of these filesystems is mounted with writes enabled, any UID or GID that would exceed 65535 is translated to the overflow value before being written to disk.
The file super-max controls the maximum number of superblocks, and thus the maximum number of mounted filesystems the kernel can have. You only need to increase super-max if you need to mount more filesystems than the current value in super-max allows you to. The file super-nr contains the number of filesystems currently mounted.
The file acct contains three numbers: highwater, lowwater and frequency. If BSD-style process accounting is enabled these values control its behaviour. If free space on filesystem where the log lives goes below lowwater percent accounting suspends. If free space gets above highwater percent accounting resumes. Frequency determines how often the kernel checks the amount of free space (value is in seconds). Default values are 4, 2 and 30. That is, suspend accounting if <= 2% of space is free; resume it if >= 4% of space is free; consider information about amount of free space valid for 30 seconds.
The file cap-bound holds the value of the kernel capability bounding set (expressed as a signed decimal number). This set is ANDed against the capabilities permitted to a process during exec.
The file core_uses_pid can be used control the naming of a core dump file on Linux 2.4. If this file contains the value 0, then a core dump file is simply named core. If this file contains a non-zero value, then the core dump file includes the process ID in a name of the form core.PID.
The file ctrl-alt-del controls the handling of Ctrl-Alt-Del from the keyboard. When the value in this file is 0, Ctrl-Alt-Del is trapped and sent to the init(1) program to handle a graceful restart. When the value is > 0, Linux's reaction to a Vulcan Nerve Pinch (tm) will be an immediate reboot, without even syncing its dirty buffers. Note: when a program (like dosemu) has the keyboard in 'raw' mode, the ctrl-alt-del is intercepted by the program before it ever reaches the kernel tty layer, and it's up to the program to decide what to do with it.
The files
domainname and
hostname
can be used to set the NIS/YP domainname and the
hostname of your box in exactly the same way as the commands
domainname and hostname, i.e.:
# echo "darkstar" > /proc/sys/kernel/hostname
# echo "mydomain" > /proc/sys/kernel/domainname
has the same effect as
# hostname "darkstar"
# domainname "mydomain"
Note, however, that the classic darkstar.frop.org has the
hostname "darkstar" and DNS (Internet Domain Name Server)
domainname "frop.org", not to be confused with the NIS (Network
Information Service) or YP (Yellow Pages) domainname. These two
domain names are in general different. For a detailed discussion
see the
hostname(1)
man page.
If the file htab-reclaim (PowerPC only) is set to a non-zero value, the PowerPC htab (see kernel file Documentation/powerpc/ppc_htab.txt) is pruned each time the system hits the idle loop.
The file l2cr (PowerPC only) contains a flag that controls the L2 cache of G3 processor boards. If 0, the cache is disabled. Enabled if nonzero.
The file modprobe is described by the kernel source file Documentation/kmod.txt.
The file msgmax is a system-wide limit specifying the maximum number of bytes in a single message written on a System V message queue.
The file msgmni defines the system-wide limit on the number of message queue identifiers. (This file is only present in Linux 2.4 onwards.)
The file msgmnb is a system-wide paramter used to initialise the msg_qbytes setting for subsequenly created message queues. The msg_qbytes setting specifies the maximum number of bytes that may be written to the message queue.
The files ostype and osrelease give substrings of /proc/version.
The files overflowgid and overflowuid duplicate the files /proc/sys/fs/overflowgid and /proc/sys/fs/overflowuid.
The file panic gives read/write access to the kernel variable panic_timeout. If this is zero, the kernel will loop on a panic; if nonzero it indicates that the kernel should autoreboot after this number of seconds. When you use the software watchdog device driver, the recommended setting is 60.
The file powersave-nap (PowerPC only) contains a flag. If set, Linux-PPC will use the 'nap' mode of powersaving, otherwise the 'doze' mode will be used.
The four values in the file printk are console_loglevel, default_message_loglevel, minimum_console_level and default_console_loglevel. These values influence printk() behavior when printing or logging error messages. See syslog(2) for more info on the different loglevels. Messages with a higher priority than console_loglevel will be printed to the console. Messages without an explicit priority will be printed with priority default_message_level. minimum_console_loglevel is the minimum (highest) value to which console_loglevel can be set. default_console_loglevel is the default value for console_loglevel.
The directory random contains various parameters controlling the operation of the file /dev/random.
The file real-root-dev is documented in the kernel source file Documentation/initrd.txt.
The file reboot-cmd (Sparc only) seems to be a way to give an argument to the SPARC ROM/Flash boot loader. Maybe to tell it what to do after rebooting?
The file rtsig-max can be used to tune the maximum number of POSIX realtime (queued) signals that can be outstanding in the system.
The file rtsig-nr shows the number POSIX realtime signals currently queued.
The file sem (available in Linux 2.4 onwards) contains 4 numbers defining limits for System V IPC semaphores. These fields are, in order:
The file sg-big-buff shows the size of the generic SCSI device (sg) buffer. You can't tune it just yet, but you could change it on compile time by editing include/scsi/sg.h and changing the value of SG_BIG_BUFF. However, there shouldn't be any reason to change this value.
The file shmall contains the system-wide limit on the total number of pages of System V shared memory.
The file shmmax can be used to query and set the run time limit on the maximum (System V IPC) shared memory segment size that can be created. Shared memory segments up to 1Gb are now supported in the kernel. This value defaults to SHMMAX.
The file shmmni (available in Linux 2.4 and onwards) specifies the system-wide maximum number of System V shared memory segments that can be created.
The file
version
contains a string like:
#5 Wed Feb 25 21:49:24 MET 1998.TP
The '#5' means that
this is the fifth kernel built from this source base and the
date behind it indicates the time the kernel was built.
The file zero-paged (PowerPC only) contains a flag. When enabled (non-zero), Linux-PPC will pre-zero pages in the idle loop, possibly speeding up get_free_pages.
Linux version 1.0.9 (quinlan@phaze) #1 Sat May 14 01:51:54 EDT 1994
Last updated for Linux 2.4.17.
This manual page is incomplete, possibly inaccurate, and is the kind of thing that needs to be updated very often.