Procfs
Encyclopedia
procfs is a special filesystem in UNIX-like
operating systems that presents information about process
es and other system information in a hierarchical file-like structure, providing a more convenient and standardized method for dynamically accessing process data held in the kernel than traditional tracing
methods or direct access to kernel
memory. Typically, it is mapped to a mount point named
Operating systems that support the proc filesystem include, but are not limited to:
The proc filesystem helps to move functionality from kernel space to user space
. For example, the GNU
version of
version of
in June 1984. The design of procfs aimed to replace the ptrace
system call used for process tracing. Detailed documentation could be found in the proc(4) manual page.
implemented a process file system, but went further than V8. V8's process file system implemented a single file per process. Plan 9 created a hierarchy of separate files to provide those functions, and made /proc a real part of the file system.
. Under Linux,
Obtaining the PID
can be done with utilities like pgrep
, pidof
or ps
:
It also includes non-process-related system information, although in the 2.6 kernel much of that information moved to a separate pseudo-file system, sysfs
, mounted under
On multi-core CPUs, /proc/cpuinfo contains the two fields "siblings" and "cpu cores" whereas the following calculation is applied:
A CPU package means physical CPU which can have multiple cores (single core for none, dual core for two, quad core for four).
This allows to better distinguish between HT and dual-core, i.e. the number of HT per CPU package can be calculated by siblings / CPU cores. If both values for a CPU package are the same, then hyper-threading is not supported. For instance, a CPU package with siblings=2 and "cpu cores"=2 is a dual-core CPU but doesn't support HT.
The basic utilities that use /proc under Linux come in the procps (/proc processes) package, and only function in conjunction with a mounted
added additional functions to
Unix-like
A Unix-like operating system is one that behaves in a manner similar to a Unix system, while not necessarily conforming to or being certified to any version of the Single UNIX Specification....
operating systems that presents information about process
Process (computing)
In computing, a process is an instance of a computer program that is being executed. It contains the program code and its current activity. Depending on the operating system , a process may be made up of multiple threads of execution that execute instructions concurrently.A computer program is a...
es and other system information in a hierarchical file-like structure, providing a more convenient and standardized method for dynamically accessing process data held in the kernel than traditional tracing
Tracing (software)
In software engineering, tracing is a specialized use of logging to record information about a program's execution. This information is typically used by programmers for debugging purposes, and additionally, depending on the type and detail of information contained in a trace log, by experienced...
methods or direct access to kernel
Kernel (computing)
In computing, the kernel is the main component of most computer operating systems; it is a bridge between applications and the actual data processing done at the hardware level. The kernel's responsibilities include managing the system's resources...
memory. Typically, it is mapped to a mount point named
/proc
at boot time.Operating systems that support the proc filesystem include, but are not limited to:
- Solaris
- IRIXIRIXIRIX is a computer operating system developed by Silicon Graphics, Inc. to run natively on their 32- and 64-bit MIPS architecture workstations and servers. It was based on UNIX System V with BSD extensions. IRIX was the first operating system to include the XFS file system.The last major version...
- Tru64 UNIXTru64 UNIXTru64 UNIX is a 64-bit UNIX operating system for the Alpha instruction set architecture , currently owned by Hewlett-Packard . Previously, Tru64 UNIX was a product of Compaq, and before that, Digital Equipment Corporation , where it was known as Digital UNIX .As its original name suggests, Tru64...
- BSDBerkeley Software DistributionBerkeley Software Distribution is a Unix operating system derivative developed and distributed by the Computer Systems Research Group of the University of California, Berkeley, from 1977 to 1995...
- LinuxLinuxLinux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. The defining component of any Linux system is the Linux kernel, an operating system kernel first released October 5, 1991 by Linus Torvalds...
(which extends it to non-process-related data) - IBM AIX (which bases its implementation on Linux to improve compatibility)
- QNXQNXQNX is a commercial Unix-like real-time operating system, aimed primarily at the embedded systems market. The product was originally developed by Canadian company, QNX Software Systems, which was later acquired by Canadian BlackBerry-producer Research In Motion.-Description:As a microkernel-based...
- Plan 9 from Bell LabsPlan 9 from Bell LabsPlan 9 from Bell Labs is a distributed operating system. It was developed primarily for research purposes as the successor to Unix by the Computing Sciences Research Center at Bell Labs between the mid-1980s and 2002...
The proc filesystem helps to move functionality from kernel space to user space
User space
A conventional computer operating system usually segregates virtual memory into kernel space and user space. Kernel space is strictly reserved for running the kernel, kernel extensions, and most device drivers...
. For example, the GNU
GNU
GNU is a Unix-like computer operating system developed by the GNU project, ultimately aiming to be a "complete Unix-compatible software system"...
version of
psPs (Unix)In most Unix-like operating systems, the ps program displays the currently-running processes. A related Unix utility named top provides a real-time view of the running processes....
operates entirely in user mode, using the procfs to obtain its data.UNIX 8th Edition
Tom J. Killian implemented the UNIX 8th EditionVersion 8 Unix
Eighth Edition Unix, also known as Version 8 Unix or V8, was a version of the Research Unix operating system developed and used internally at Bell Labs and a select number of universities. It was "released" in February 1985, ran on VAX hardware, and was a variant of 4.1cBSD with some System V.1 ...
version of
/proc
: he presented a paper titled "Processes as Files" at USENIXUSENIX
-External links:* *...
in June 1984. The design of procfs aimed to replace the ptrace
Ptrace
ptrace is a system call found in several Unix and Unix-like operating systems. By using ptrace one process can control another, enabling the controller to inspect and manipulate the internal state of its target...
system call used for process tracing. Detailed documentation could be found in the proc(4) manual page.
SVR4
Roger Faulkner and Ron Gomes ported V8/proc
to SVR4, and published a paper called "The Process File System and Process Model in UNIX System V" at USENIX in January 1991. This kind of procfs supported the creation of psPs (Unix)In most Unix-like operating systems, the ps program displays the currently-running processes. A related Unix utility named top provides a real-time view of the running processes....
, but the files could only be accessed with functions read
, write
, and ioctlIoctlIn computing, ioctl, short for input/output control, is a system call for device-specific operations and other operations which cannot be expressed by regular system calls. It takes a parameter specifying a request code; the effect of a call depends completely on the request code. Request codes are...
.Plan 9
Plan 9Plan 9 from Bell Labs
Plan 9 from Bell Labs is a distributed operating system. It was developed primarily for research purposes as the successor to Unix by the Computing Sciences Research Center at Bell Labs between the mid-1980s and 2002...
implemented a process file system, but went further than V8. V8's process file system implemented a single file per process. Plan 9 created a hierarchy of separate files to provide those functions, and made /proc a real part of the file system.
4.4BSD
4.4BSD cloned its implementation of/proc
from Plan 9. Note that in FreeBSD procfs is being gradually phased out.Solaris
Solaris 2.6's/proc
(finished in 1996) also cloned Plan 9.Linux
The Linux implementation of/proc
also clones that of Plan 9Plan 9 from Bell Labs
Plan 9 from Bell Labs is a distributed operating system. It was developed primarily for research purposes as the successor to Unix by the Computing Sciences Research Center at Bell Labs between the mid-1980s and 2002...
. Under Linux,
/proc
includes a directory for each running process (including kernel processes) at /proc/PID
, containing information about that process, notably including:
-
/proc/PID/cmdline
, which contains the command which originally started the process. -
/proc/PID/cwd
, a symlink to the current working directoryWorking directoryIn computing, the working directory of a process is a directory of a hierarchical file system, if any, dynamically associated with each process. When the process refers to a file using a simple file name or relative path , the reference is interpreted relative to the current working directory of...
of the process. -
/proc/PID/environ
, a file containing the names and contents of the environment variables that affect the process. -
/proc/PID/exe
, a symlink to the original executable file, if it still exists (a process may continue running after its original executable has been deleted or replaced). -
/proc/PID/fd
, a directory containing a symbolic link for each open file descriptorFile descriptorIn computer programming, a file descriptor is an abstract indicator for accessing a file. The term is generally used in POSIX operating systems...
. -
/proc/PID/fdinfo
, a directory containing files which describe the position and flags for each open file descriptor. -
/proc/PID/root
, a symlink to the root path as seen by the process. For most processes this will be a link to / unless the process is running in a chroot jail. -
/proc/PID/status
, a file containing basic information about a process including its run state and memory usage. -
/proc/PID/task
, a directory containing hard links to any tasks that have been started by this (i.e.: the parent) process. -
/proc/PID/maps
, the memory map showing which addresses currently visible to that process are mapped to which regions in RAM or to files.
Obtaining the PID
PID
-Medicine:*Prolapsed intervertebral disc, commonly called a "herniated disc"*Primary immune deficiency, disorders in which part of the body's immune system is missing or does not function properly...
can be done with utilities like pgrep
Pgrep
pgrep is a command-line utility initially written for use with the Solaris 7 operating system. It has since been reimplemented for Linux and the BSDs . It searches for all the named processes that can be specified as extended regular expression patterns, and—by default—returns their process ID...
, pidof
Pidof
pidof is a Linux utility that returns the process identifier of a running process or processes. On other operating systems, pgrep and ps are often used instead....
or ps
Ps (Unix)
In most Unix-like operating systems, the ps program displays the currently-running processes. A related Unix utility named top provides a real-time view of the running processes....
:
It also includes non-process-related system information, although in the 2.6 kernel much of that information moved to a separate pseudo-file system, sysfs
Sysfs
Sysfs is a virtual file system provided by Linux 2.6. Sysfs exports information about devices and drivers from the kernel device model to user space, and is also used for configuration...
, mounted under
/sys
:- depending on the mode of power management (if at all), either directory,
/proc/acpi
or/proc/apm
, which predate sysfs and contain various bits of information about the state of power management. -
/proc/buddyinfo
, information about the buddy algorithm which handles memory fragmentation. -
/proc/bus
, containing directories representing various buses on the computer, such as input/PCIPeripheral Component InterconnectConventional PCI is a computer bus for attaching hardware devices in a computer...
/USBUniversal Serial BusUSB is an industry standard developed in the mid-1990s that defines the cables, connectors and protocols used in a bus for connection, communication and power supply between computers and electronic devices....
. This has been largely superseded by sysfs under /sys/bus which is far more informative. -
/proc/fb
, a list of the available framebuffers -
/proc/cmdline
, giving the boot options passed to the kernel -
/proc/cpuinfo
, containing information about the CPU, such as its vendor (and CPU family, model and model names which should allow users to identify the CPU) and its speed (CPU clockspeedClock rateThe clock rate typically refers to the frequency that a CPU is running at.For example, a crystal oscillator frequency reference typically is synonymous with a fixed sinusoidal waveform, a clock rate is that frequency reference translated by electronic circuitry into a corresponding square wave...
), cache size, number of siblings, cores, and CPU flags. It contains a value called "bogomipsBogoMipsBogoMips is an unscientific measurement of CPU speed made by the Linux kernel when it boots, to calibrate an internal busy-loop...
", frequently misunderstood as measure CPU-speed like a benchmark, while it doesn't actually measure any sensible (for end-users) value at all. It occurs as a side-effect of kernel timer calibration and yields highly varying values depending on CPU type, even at equal clock speeds.
On multi-core CPUs, /proc/cpuinfo contains the two fields "siblings" and "cpu cores" whereas the following calculation is applied:
"siblings" = (HT per CPU package) * (# of cores per CPU package)
"cpu cores" = (# of cores per CPU package)
A CPU package means physical CPU which can have multiple cores (single core for none, dual core for two, quad core for four).
This allows to better distinguish between HT and dual-core, i.e. the number of HT per CPU package can be calculated by siblings / CPU cores. If both values for a CPU package are the same, then hyper-threading is not supported. For instance, a CPU package with siblings=2 and "cpu cores"=2 is a dual-core CPU but doesn't support HT.
-
/proc/crypto
, a list of available cryptographic modules -
/proc/devices
, a list of character and block devices sorted by device ID but giving the major part of the/dev
name too -
/proc/diskstats
, giving some information (including device numbers) for each of the logical disk devices -
/proc/filesystems
, a list of the file systems supported by the kernel at the time of listing -
/proc/interrupts
,/proc/iomem
,/proc/ioports
and the directory/proc/irq
, giving some self-explanatory details about the devices (physical or logical) using the various system resources -
/proc/meminfo
, containing a summary of how the kernel is managing its memory. -
/proc/modules
, one of the most important files in/proc
, containing a list of the kernel modules currently loaded . It gives some indication ( not always entirely correct) of dependencies. -
/proc/mounts
, a symlink to self/mounts which contains a list of the currently mounted devices and their mount points (and which file system is in use and what mount options are in use). -
/proc/net
, a directory containing a lot of really useful information about the network stack, in particular nf_conntrack which lists existing network connections (particularly useful for tracking routing when iptablesIptablesiptables is a user space application program that allows a system administrator to configure the tables provided by the Linux kernel firewall and the chains and rules it stores...
FORWARD is used to redirect network connections). -
/proc/partitions
, a list of the device-numbers, their size and/dev
names which the kernel has identified as existing partitionsDisk partitioningDisk partitioning is the act of dividing a hard disk drive into multiple logical storage units referred to as partitions, to treat one physical disk drive as if it were multiple disks. Partitions are also termed "slices" for operating systems based on BSD, Solaris or GNU Hurd...
(for example if /dev/sda contains a partition table, then /dev/sda1 and others will appear as available partitions). Note that if a partition isn't listed in this file, then a patched version of losetup is around which can essentially mount the partition and connect /dev/loop[n] devices to the various partitions (though it is not certain if these will then appear in/proc/partitions
). -
/proc/scsi
, giving information about any devices connected via a SCSISCSISmall Computer System Interface is a set of standards for physically connecting and transferring data between computers and peripheral devices. The SCSI standards define commands, protocols, and electrical and optical interfaces. SCSI is most commonly used for hard disks and tape drives, but it...
or RAIDRAIDRAID is a storage technology that combines multiple disk drive components into a logical unit...
controller - a symbolic link to the current (traversing) process at
/proc/self
(i.e./proc/PID/
where PIDProcess identifierIn computing, the process identifier is a number used by most operating system kernels to uniquely identify a process...
is that of the current process). -
/proc/slabinfo
, listing statistics on the caches for frequently-used objects in the Linux kernel -
/proc/swaps
, a list of the active swap partitions, their various sizes and priorities - Access to dynamically-configurable kernel options under
/proc/sys
. Under/proc/sys
appear directories representing the areas of kernel, containing readable and writable virtual files.
For example, a commonly referenced virtual file is/proc/sys/net/ipv4/ip_forward
, because it is necessary for routing firewalls or tunnels. The file contains either a '1' or a '0': if it is 1 then the IPv4 stack will forward packets not meant for the local host, if it is 0 then it will not. -
/proc/sysvipc
, containing memory sharing and IPCInter-process communicationIn computing, Inter-process communication is a set of methods for the exchange of data among multiple threads in one or more processes. Processes may be running on one or more computers connected by a network. IPC methods are divided into methods for message passing, synchronization, shared...
information. -
/proc/tty
, containing information about the current terminals;/proc/tty/driver
looks to be a list of the different types of ttyTTYTTY may stand for:* Teleprinter or Teletypewriter or Teletype Printer, a typewriter paired with an electronic communication channel, used for telecommunications or as a computer terminal....
available each of which is a list of those of each type -
/proc/uptime
, the length of time the kernel has been running since boot and spent in idle mode (both in seconds) -
/proc/version
, containing the Linux kernel version, distribution number, gccGNU Compiler CollectionThe GNU Compiler Collection is a compiler system produced by the GNU Project supporting various programming languages. GCC is a key component of the GNU toolchain...
version number (used to build the kernel) and any other pertinent information relating to the version of the kernel currently running - other files depending on various hardware, module configurations, and changes to the kernel.
The basic utilities that use /proc under Linux come in the procps (/proc processes) package, and only function in conjunction with a mounted
/proc
.Cobalt
Cobalt NetworksCobalt Networks
Cobalt Networks was a maker of low-cost Linux-based servers. Founded in 1996 in Mountain View, California under the name Cobalt Microserver, the company pioneered easy-to-use server appliances featuring secure web user interfaces, designed for Internet service providers and small to medium sized...
added additional functions to
/proc
for their systems:
-
/proc/cobalt
, a directory containing Cobalt-specific data such as the system type and serial number. -
/proc/lcd
, a file containing the contents of the front-panel LCD screen. Text written to this file would be displayed on the screen.
External links
- A brief history of /proc Eric Schrock's Weblog
- Access the Linux kernel using the Procfs An IBM developerWorks article by M. Tim Jones
- Linux-Filesystem-Hierarchy Linux Documentation Project
- Creating and using proc files - an article from the Real-Time Embedded blog
- Using the proc filesystem An article by Pétur I. Egilsson