The proc filesystem (procfs) is a special filesystem in
Unix-like
A Unix-like (sometimes referred to as UN*X or *nix) operating system is one that behaves in a manner similar to a Unix system, although not necessarily conforming to or being certified to any version of the Single UNIX Specification. A Unix-li ...
operating systems that presents information about
process
A process is a series or set of activities that interact to produce a result; it may occur once-only or be recurrent or periodic.
Things called a process include:
Business and management
*Business process, activities that produce a specific se ...
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 may refer to:
Computer graphics
* Image tracing, digital image processing to convert raster graphics into vector graphics
* Path tracing, a method of rendering images of three-dimensional scenes such that the global illumination is faithf ...
methods or direct access to
kernel
Kernel may refer to:
Computing
* Kernel (operating system), the central component of most operating systems
* Kernel (image processing), a matrix used for image convolution
* Compute kernel, in GPGPU programming
* Kernel method, in machine learnin ...
memory. Typically, it is mapped to a
mount point
Mounting is a process by which a computer's operating system makes files and directories on a storage device (such as hard drive, CD-ROM, or network share) available for users to access via the computer's file system.
In general, the process ...
named ''/proc'' at boot time. The proc file system acts as an interface to internal data structures about running processes in the kernel. In
Linux
Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, which ...
, it can also be used to obtain information about the kernel and to change certain kernel parameters at runtime (
sysctl
sysctl is a software utility of some Unix-like operating systems that reads and modifies the attributes of the system kernel such as its version number, maximum limits, and security settings. It is available both as a system call for compiled ...
).
Many Unix-like operating systems support the proc filesystem, including
Solaris
Solaris may refer to:
Arts and entertainment Literature, television and film
* ''Solaris'' (novel), a 1961 science fiction novel by Stanisław Lem
** ''Solaris'' (1968 film), directed by Boris Nirenburg
** ''Solaris'' (1972 film), directed by ...
,
IRIX
IRIX ( ) is a discontinued operating system developed by Silicon Graphics (SGI) to run on the company's proprietary MIPS workstations and servers. It is based on UNIX System V with BSD extensions. In IRIX, SGI originated the XFS file system and ...
,
Tru64 UNIX
Tru64 UNIX is a discontinued 64-bit UNIX operating system for the Alpha instruction set architecture (ISA), currently owned by Hewlett-Packard (HP). Previously, Tru64 UNIX was a product of Compaq, and before that, Digital Equipment Corporation ( ...
,
BSD
The Berkeley Software Distribution or Berkeley Standard Distribution (BSD) is a discontinued operating system based on Research Unix, developed and distributed by the Computer Systems Research Group (CSRG) at the University of California, Berk ...
,
Linux
Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, which ...
,
IBM AIX
AIX (Advanced Interactive eXecutive, pronounced , "ay-eye-ex") is a series of Proprietary software, proprietary Unix operating systems developed and sold by IBM for several of its computer platforms.
Background
Originally released for the ...
,
QNX
QNX ( or ) is a commercial Unix-like real-time operating system, aimed primarily at the embedded systems market. QNX was one of the first commercially successful microkernel operating systems.
The product was originally developed in the early ...
, and
Plan 9 from Bell Labs
Plan 9 from Bell Labs is a distributed operating system which originated from the Computing Science Research Center (CSRC) at Bell Labs in the mid-1980s and built on UNIX concepts first developed there in the late 1960s. Since 2000, Plan 9 has be ...
.
OpenBSD
OpenBSD is a security-focused, free and open-source, Unix-like operating system based on the Berkeley Software Distribution (BSD). Theo de Raadt created OpenBSD in 1995 by forking NetBSD 1.0. According to the website, the OpenBSD project em ...
dropped support in version 5.7, released in May 2015. It is absent from
HP-UX
HP-UX (from "Hewlett Packard Unix") is Hewlett Packard Enterprise's proprietary implementation of the Unix operating system, based on Unix System V (initially System III) and first released in 1984. Current versions support HPE Integrity Ser ...
and
macOS
macOS (; previously OS X and originally Mac OS X) is a Unix operating system developed and marketed by Apple Inc. since 2001. It is the primary operating system for Apple's Mac computers. Within the market of desktop and lapt ...
.
The
Linux kernel
The Linux kernel is a free and open-source, monolithic, modular, multitasking, Unix-like operating system kernel. It was originally authored in 1991 by Linus Torvalds for his i386-based PC, and it was soon adopted as the kernel for the GNU ope ...
extends it to non–process-related data.
The proc filesystem provides a method of communication between
kernel space
A modern computer operating system usually segregates virtual memory into user space and kernel space. Primarily, this separation serves to provide memory protection and hardware protection from malicious or errant software behaviour.
Kernel ...
and
user space
A modern computer operating system usually segregates virtual memory into user space and kernel space. Primarily, this separation serves to provide memory protection and hardware protection from malicious or errant software behaviour.
Kernel ...
. For example, the
GNU
GNU () is an extensive collection of free software (383 packages as of January 2022), which can be used as an operating system or can be used in parts with other operating systems. The use of the completed GNU tools led to the family of operat ...
version of the process reporting utility
ps uses the proc file system to obtain its data, without using any specialized
system calls
In computing, a system call (commonly abbreviated to syscall) is the programmatic way in which a computer program requests a service from the operating system on which it is executed. This may include hardware-related services (for example, acc ...
.
History
UNIX 8th Edition
Tom J. Killian implemented the
UNIX 8th Edition (V8) version of ''/proc'': he presented a paper title
"Processes as Files"at
USENIX in June 1984. The design of procfs aimed to replace the ''
ptrace
ptrace is a system call found in Unix and several Unix-like operating systems. By using ptrace (the name is an abbreviation of "process trace") one process can control another, enabling the controller to inspect and manipulate the internal state ...
'' system call used for process tracing. Detailed documentation can be found in th
proc(4) manual page
SVR4
Roger Faulkner
Roger is a given name, usually masculine, and a surname. The given name is derived from the Old French personal names ' and '. These names are of Germanic origin, derived from the elements ', ''χrōþi'' ("fame", "renown", "honour") and ', ' ( ...
and
Ron Gomes Ron is a shortening of the name Ronald.
Ron or RON may also refer to:
Arts and media
* Big Ron (''EastEnders''), a TV character
* Ron (''King of Fighters''), a video game character
*Ron Douglas, the protagonist in ''Lucky Stiff'' played by Joe ...
ported V8 ''/proc'' to
SVR4
Unix System V (pronounced: "System Five") is one of the first commercial versions of the Unix operating system. It was originally developed by AT&T and first released in 1983. Four major versions of System V were released, numbered 1, 2, 3, an ...
, and published a paper calle
"The Process File System and Process Model in UNIX System V"at USENIX in January 1991. This kind of procfs supported the creation of ''
ps'', but the files could only be accessed with functions ''read()'', ''write()'', and ''
ioctl
In computing, ioctl (an abbreviation of input/output control) is a system call for device-specific input/output operations and other operations which cannot be expressed by regular system calls. It takes a parameter specifying a request code; th ...
()''. Between 1995 and 1996, Roger Faulkner created the procfs-2 interface for Solaris-2.6 that offers a structured /proc filesystem with sub-directories.
Plan 9
Plan 9 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 The History of the Berkeley Software Distribution begins in the 1970s.
1BSD (PDP-11)
The earliest distributions of Unix from Bell Labs in the 1970s included the source code to the operating system, allowing researchers at universities to modify a ...
cloned its implementation of from Plan 9. , procfs is gradually becoming phased out in FreeBSD, and turned to use the
sysctl
sysctl is a software utility of some Unix-like operating systems that reads and modifies the attributes of the system kernel such as its version number, maximum limits, and security settings. It is available both as a system call for compiled ...
instead for process-related information. It was removed from
OpenBSD
OpenBSD is a security-focused, free and open-source, Unix-like operating system based on the Berkeley Software Distribution (BSD). Theo de Raadt created OpenBSD in 1995 by forking NetBSD 1.0. According to the website, the OpenBSD project em ...
in version 5.7, which was released in May 2015, because it "always suffered from race conditions and is now unused".
macOS
macOS (; previously OS X and originally Mac OS X) is a Unix operating system developed and marketed by Apple Inc. since 2001. It is the primary operating system for Apple's Mac computers. Within the market of desktop and lapt ...
didn't implement procfs and user space programs have to use sysctl interface for processes data.
To provide binary compatibility with Linux user space programs, FreeBSD kernel also provides linprocfs that is similar to the Linux procfs.
Solaris
/proc in Solaris was available from the beginning. Solaris 2.6 in 1996 introduced procfs2 from Roger Faulkner.
Linux
Linux first added a /proc filesystem i
v0.97.3 September 1992, and first began expanding it to non-process related data in v0.98.6, December 1992.
As of 2020, the Linux implementation includes a directory for each running process, including
kernel
Kernel may refer to:
Computing
* Kernel (operating system), the central component of most operating systems
* Kernel (image processing), a matrix used for image convolution
* Compute kernel, in GPGPU programming
* Kernel method, in machine learnin ...
processes, in directories named , where is the process number. Each directory contains information about one process, including:
* , the command that originally started the process.
* , a
symlink to the
current working directory
In computing, the working directory of a process is a directory of a hierarchical file system, if any, dynamically associated with each process. It is sometimes called the current working directory (CWD), e.g. the BSD getcwd function, or just ...
of the process.
* contains the names and values of the environment variables that affect the process.
* , a symlink to the original
executable file
In computing, executable code, an executable file, or an executable program, sometimes simply referred to as an executable or binary, causes a computer "to perform indicated tasks according to encoded instructions", as opposed to a data file ...
, if it still exists (a process may continue running after its original executable has been deleted or replaced).
* , a directory containing a symbolic link for each open
file descriptor
In Unix and Unix-like computer operating systems, a file descriptor (FD, less frequently fildes) is a process-unique identifier (handle) for a file or other input/output resource, such as a pipe or network socket.
File descriptors typically have ...
.
* , a directory containing entries which describe the position and flags for each open file descriptor.
* , a text file containing information about
mapped files and blocks (like heap and stack).
* , a binary image representing the process's
virtual memory
In computing, virtual memory, or virtual storage is a memory management technique that provides an "idealized abstraction of the storage resources that are actually available on a given machine" which "creates the illusion to users of a very l ...
, can only be accessed by a
ptrace
ptrace is a system call found in Unix and several Unix-like operating systems. By using ptrace (the name is an abbreviation of "process trace") one process can control another, enabling the controller to inspect and manipulate the internal state ...
'ing process.
* , 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.
* contains basic information about a process including its run state and memory usage.
* , a directory containing
hard links
In computing, a hard link is a directory entry (in a directory-based file system) that associates a name with a file. Thus, each file must have at least one hard link. Creating additional hard links for a file makes the contents of that file acc ...
to any tasks that have been started by this (i.e.: the parent) process.
(Users may obtain the
PID with a utility such as
pgrep
pgrep is a command-line utility initially written for use with the Solaris 7 operating system by Mike Shapiro. It has since been available in illumos and reimplemented for the Linux and BSDs (DragonFly BSD, FreeBSD, NetBSD, and OpenBSD). It sea ...
,
pidof or
ps:
$ ls -l /proc/$(pgrep -n python3)/fd # List all file descriptors of the most recently started `python3' process
total 0
lrwx------ 1 baldur baldur 64 2020-03-18 12:31 0 -> /dev/pts/3
lrwx------ 1 baldur baldur 64 2020-03-18 12:31 1 -> /dev/pts/3
lrwx------ 1 baldur baldur 64 2020-03-18 12:31 2 -> /dev/pts/3
$ readlink /proc/$(pgrep -n python3)/exe # List executable used to launch the most recently started `python3' process
/usr/bin/python3.8
)
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 is a pseudo file system provided by the Linux kernel that exports information about various kernel subsystems, hardware devices, and associated device drivers from the kernel's device model to user space through virtual files. In addition ...
, mounted under :
* depending on the mode of power management (if at all), either directory, or , which predate sysfs and contain various bits of information about the state of power management.
* , information about the
buddy algorithm that handles memory fragmentation.
* , containing directories representing various buses on the computer, such as
PCI
PCI may refer to:
Business and economics
* Payment card industry, businesses associated with debit, credit, and other payment cards
** Payment Card Industry Data Security Standard, a set of security requirements for credit card processors
* Pro ...
/
USB
Universal Serial Bus (USB) is an industry standard that establishes specifications for cables, connectors and protocols for connection, communication and power supply (interfacing) between computers, peripherals and other computers. A broad ...
. This has been largely superseded by
sysfs
sysfs is a pseudo file system provided by the Linux kernel that exports information about various kernel subsystems, hardware devices, and associated device drivers from the kernel's device model to user space through virtual files. In addition ...
under /sys/bus which is far more informative.
* , a list of the available framebuffers
* , giving the boot options passed to the kernel
* , 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
clockspeed), cache size, number of siblings, cores, and
CPU flags. includes a value for "
bogomips
BogoMips (from "bogus" and MIPS) is a crude measurement of CPU speed made by the Linux kernel when it boots to calibrate an internal busy-loop. An often-quoted definition of the term is "the number of million times per second a processor can do a ...
", frequently misconstrued as a measure of CPU speed, like a benchmark, but it does not 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 fields for "siblings" and "cpu cores" which represent 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 one, ''dual core'' for two, ''quad core'' for four).
This allows a distinction between
hyper-threading
Hyper-threading (officially called Hyper-Threading Technology or HT Technology and abbreviated as HTT or HT) is Intel's proprietary simultaneous multithreading (SMT) implementation used to improve parallelization of computations (doing multip ...
and dual-core, i.e. the number of hyper-threads 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 does not support hyper-threading.
* , a list of available cryptographic modules
* , a list of character and block devices sorted by device ID but giving the major part of the name too
* , giving some information (including device numbers) for each of the logical disk devices
* , a list of the file systems supported by the kernel at the time of listing
* , , and the directory , giving some details about the devices (physical or logical) using the various
system resource
In computing, a system resource, or simple resource, is any physical or virtual component of limited availability within a computer system. All connected devices and internal system components are resources. Virtual system resources include fi ...
s
* , holding messages output by the kernel
[
]
* , containing a summary of how the kernel is managing its memory.
* , one of the most important files in , containing a list of the kernel modules currently loaded . It gives some indication (not always entirely correct) of dependencies.
* , 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).
* , a directory containing useful information about the network stack, in particular , which lists existing network connections (particularly useful for tracking routing when
iptables
iptables is a user-space utility program that allows a system administrator to configure the IP packet filter rules of the Linux kernel firewall, implemented as different Netfilter modules. The filters are organized in different tables, which ...
FORWARD is used to redirect network connections)
* , a list of the device-numbers, their size and names which the kernel has identified as existing
partitions
Partition may refer to:
Computing Hardware
* Disk partitioning, the division of a hard disk drive
* Memory partition, a subdivision of a computer's memory, usually for use by a single job
Software
* Partition (database), the division of a ...
* , giving information about any devices connected via a
SCSI
Small Computer System Interface (SCSI, ) is a set of standards for physically connecting and transferring data between computers and peripheral devices. The SCSI standards define commands, protocols, electrical, optical and logical interface ...
or
RAID
Raid, RAID or Raids may refer to:
Attack
* Raid (military), a sudden attack behind the enemy's lines without the intention of holding ground
* Corporate raid, a type of hostile takeover in business
* Panty raid, a prankish raid by male college ...
controller
* a symbolic link to the current (traversing) process at (i.e. where
PID is that of the current process).
* , listing statistics on the caches for frequently-used objects in the Linux kernel
* , a list of the active swap partitions, their various sizes and priorities
* Access to dynamically configurable kernel options under . Under appear directories representing the areas of kernel, containing readable and writable
virtual file
In computing, file system or filesystem (often abbreviated to fs) is a method and data structure that the operating system uses to control how data is stored and retrieved. Without a file system, data placed in a storage medium would be one larg ...
s.
For example, a commonly referenced virtual file is , because it is necessary for routing firewalls or tunnels. The file contains either a '1' or a '0': if it is 1, the IPv4 stack forwards packets not meant for the local host, if it is 0 then it does not.
* , containing memory-sharing and
inter-process communication
In computer science, inter-process communication or interprocess communication (IPC) refers specifically to the mechanisms an operating system provides to allow the processes to manage shared data. Typically, applications can use IPC, categori ...
(IPC) information.
* , containing information about the current terminals; looks to be a list of the different types of
tty available - each of which is a list of those of each type
* , the length of time the kernel has been running since boot and spent in idle mode (both in seconds)
* , containing the Linux kernel version, distribution number,
gcc 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 ( processes) package, and only function in conjunction with a mounted .
CYGWIN
Cygwin
Cygwin ( ) is a POSIX-compatible programming and runtime environment that runs natively on Microsoft Windows. Under Cygwin, source code designed for Unix-like operating systems may be compiled with minimal modification and executed.
The Cygwin in ...
implemented a procfs that is basically the same as the Linux procfs.
References
Sources
Unix 8th Edition proc(2) manual page- Description of the original procfs.
Plan 9 procfs manual page- Plan 9 greatly expanded the procfs concept, providing a much expanded interface to control and manipulate processes.
Linux manual documentation for procfs
Documentation/filesystems/proc.txtLinux kernel documentation for procfs
External links
A brief history of /procEric Schrock's Weblog
An IBM developerWorks article by M. Tim Jones
Linux Documentation Project
Discover the possibilities of the /proc directoryby Federico Kereki
{{Operating system
Unix file system technology
Linux kernel features
Special-purpose file systems
Interfaces of the Linux kernel
Pseudo file systems supported by the Linux kernel