Short description: Filesystem in Unix-like operating systems
The proc filesystem (procfs) is a special filesystem in Unix-like operating systems that presents information about processes 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 /proc at boot time. The proc file system acts as an interface to internal data structures about running processes in the kernel. In Linux, it can also be used to obtain information about the kernel and to change certain kernel parameters at runtime (sysctl).
Many Unix-like operating systems support the proc filesystem, including Solaris, IRIX, Tru64 UNIX, BSD, Linux, IBM AIX,[1] QNX, and Plan 9 from Bell Labs. OpenBSD dropped support in version 5.7, released in May 2015. It is absent from HP-UX[1] and macOS.[2]
The Linux kernel extends it to non–process-related data.
The proc filesystem provides a method of communication between kernel space and user space. For example, the GNU version of the process reporting utility ps uses the proc file system to obtain its data, without using any specialized system calls.
Contents
1History
1.1UNIX 8th Edition
1.2SVR3
1.3SVR4
1.4Plan 9
1.54.4BSD and derivadives
1.6Solaris
1.7Linux
1.8CYGWIN
2References
3Sources
4External links
History
UNIX 8th Edition
Tom J. Killian implemented the UNIX 8th Edition (V8) version of /proc: he presented a paper titled "Processes as Files" at USENIX in June 1984. The design of procfs aimed to replace the ptrace system call used for process tracing. Detailed documentation can be found in the proc(4) manual page.
SVR3
The original AT&T System V Release 3 (SVR3) operating system (available internally to AT&T in 1986 and generally in 1987) did not come with the /proc filesystem, but a subsequent incremental version of it did. It only contained files representing the processes rather than the now common subdirectories.
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 ps, but the files could only be accessed with functions read(), write(), and ioctl(). 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 and derivadives
4.4BSD cloned its implementation of /proc from Plan 9.[citation needed](As of February 2011), procfs is gradually becoming phased out in FreeBSD,[3] and it has turned to use the sysctl interface instead for process-related information.
To provide binary compatibility with Linux user space programs, the FreeBSD kernel also provides linprocfs that is similar to the Linux procfs.[4]
It was removed from OpenBSD in version 5.7, which was released in May 2015, because it "always suffered from race conditions and is now unused".[5]
macOS did not implement procfs and user space programs have to use the sysctl interface for retrieving process data.[2]
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 in 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 processes, in directories named /proc/PID, where PID is the process number. Each directory contains information about one process, including:
/proc/PID/cmdline, the command that originally started the process.
/proc/PID/cwd, a symlink to the current working directory of the process.
/proc/PID/environ contains the names and values 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 descriptor.
/proc/PID/fdinfo, a directory containing entries which describe the position and flags for each open file descriptor.
/proc/PID/maps, a text file containing information about mapped files and blocks (like heap and stack).
/proc/PID/mem, a binary image representing the process's virtual memory, can only be accessed by a ptrace'ing process.
/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 contains 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.
(Users may obtain the PID with a utility such as pgrep, 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
)
/proc 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 /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 that handles memory fragmentation.[6]
/proc/bus, containing directories representing various buses on the computer, such as PCI/USB. 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 clockspeed), cache size, number of siblings, cores, and CPU flags. The format and available information is highly architecture-depended. On some architectures, /proc/cpuinfo includes a value for "bogomips", 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.
$ cat /proc/cpuinfo
processor : 0
vendor_id : AuthenticAMD
cpu family : 16
model : 6
model name : AMD Athlon(tm) II X2 270 Processor
stepping : 3
microcode : 0x10000c8
cpu MHz : 2000.000
cache size : 1024 KB
...
processor : 1
vendor_id : AuthenticAMD
cpu family : 16
model : 6
model name : AMD Athlon(tm) II X2 270 Processor
stepping : 3
microcode : 0x10000c8
cpu MHz : 800.000
cache size : 1024 KB
...
On multi-core CPUs, /proc/cpuinfo contains the fields for "siblings" and "cpu cores" which represent the following calculation is applied:[7]
"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 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.[8] For instance, a CPU package with siblings=2 and "cpu cores"=2 is a dual-core CPU but does not support hyper-threading.
/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 details about the devices (physical or logical) using the various system resources
/proc/kmsg, holding messages output by the kernel[9]
/proc/loadavg, containing stats about the current load average in the last minutes.
/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 useful information about the network stack, in particular /proc/net/nf_conntrack, which lists existing network connections (particularly useful for tracking routing when iptables 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 partitions
/proc/scsi, giving information about any devices connected via a SCSI or RAID controller
a symbolic link to the current (traversing) process at /proc/self (i.e. /proc/PID/ where PID 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, the IPv4 stack forwards packets not meant for the local host, if it is 0 then it does not.
/proc/sysvipc, containing memory-sharing and inter-process communication (IPC) information.
/proc/tty, containing information about the current terminals; /proc/tty/driver looks to be a list of the different types of tty 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, 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 (/proc processes) package, and only function in conjunction with a mounted /proc.
CYGWIN
Cygwin implemented a procfs that is basically the same as the Linux procfs.
References
↑ 1.01.1Nemeth, Evi; Snyder, Garth; Hein, Trent R.; Whaley, Ben (2010-07-14) (in en). UNIX and Linux System Administration Handbook. Pearson Education. pp. 136. ISBN 978-0-13-211736-4. https://books.google.com/books?id=rgFIAnLjb1wC&pg=PA136.
↑ 2.02.1"/proc on Mac OS X". 2003. http://osxbook.com/book/bonus/ancient/procfs/.
↑"Why is procfs deprecated in favor of procstat?". freebsd.org. 22 February 2011. http://lists.freebsd.org/pipermail/freebsd-fs/2011-February/010760.html.
↑"linprocfs(5)" (in en). The FreeBSD Project. 2019-11-13. https://www.freebsd.org/cgi/man.cgi?query=linprocfs&apropos=0&sektion=5&manpath=FreeBSD+13.0-RELEASE&arch=default&format=html. Retrieved 2021-06-12.
↑"Detailed changes between OpenBSD 5.6 and 5.7". openbsd.org. http://www.openbsd.org/plus57.html.
↑Baron, Jason. "HT vs. dual-core". http://www.redhat.com/archives/nahant-list/2006-January/msg00176.html.
↑"Understanding Linux /proc/cpuinfo". http://www.richweb.com/cpu_info.
↑Nguyen, Binh (2004-07-30). "Linux Filesystem Hierarchy". Binh Nguyen. p. 63. https://books.google.com/books?id=wLJWBQAAQBAJ. "/proc/kmsg[:] Messages output by the kernel. These are also routed to syslog."
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 Pages Proc(5) Linux manual documentation for procfs
Documentation/filesystems/proc.txt Linux kernel documentation for procfs
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
Discover the possibilities of the /proc directory by Federico Kereki
v
t
e
File systems
Comparison of file systems
distributed
Unix filesystem
Disk
ADFS
AdvFS
Amiga FFS
Amiga OFS
APFS
AthFS
bcachefs
BFS
Be File System
Boot File System
Btrfs
CVFS
CXFS
DFS
EFS
Encrypting File System
Extent File System
Episode
ext
ext2
ext3
ext3cow
ext4
FFS/FFS2
FAT
exFAT
Files-11
Fossil
HAMMER
HAMMER2
HFS
HFS+
HPFS
HTFS
IBM Spectrum Scale
JFS
LFS
MFS
Macintosh File System
TiVo Media File System
MINIX
NetWare File System
Next3
NILFS
NILFS2
NSS
NTFS
OneFS
PFS
QFS
QNX4FS
ReFS
ReiserFS
Reiser4
Reliance
Reliance Nitro
RFS
SFS
SNFS
Soup (Apple)
Tux3
UBIFS
UFS
soft updates
WAPBL
VxFS
WAFL
Xiafs
XFS
Xsan
zFS
ZFS
Optical disc
HSF
ISO 9660
ISO 13490
UDF
Flash memory and SSD
APFS
FAT
exFAT
CHFS
TFAT
EROFS
FFS2
F2FS
HPFS
JFFS
JFFS2
JFS
LogFS
NILFS
NILFS2
NVFS
YAFFS
UBIFS
Distributed
CXFS
GFS2
Google File System
OCFS2
OrangeFS
PVFS
QFS
Xsan
more...
NAS
AFS (OpenAFS)
AFP
Coda
DFS
Google File System
IBM Spectrum Scale
Lustre
NCP
NFS
POHMELFS
Hadoop
SMB (CIFS)
SSHFS
more...
Specialized
Aufs
AXFS
Boot File System
CDfs
Compact Disc File System
cramfs
Davfs2
EROFS
FTPFS
FUSE
Lnfs
LTFS
NOVA
MVFS
SquashFS
UMSDOS
OverlayFS
UnionFS
WBFS
Pseudo and virtual
configfs
devfs
debugfs
kernfs
procfs
specfs
sysfs
tmpfs
WinFS
Encrypted
eCryptfs
EncFS
EFS
Rubberhose
SSHFS
ZFS
Types
Clustered
Global
Grid
Self-certifying
Flash
Journaling
Log-structured
Object
Record-oriented
Semantic
Steganographic
Synthetic
Versioning
Features
Case preservation
Copy-on-write
Data deduplication
Data scrubbing
Execute in place
Extent
File attribute
Extended file attributes
File change log
Fork
Links
Hard
Symbolic
Access control
Access control list
Filesystem-level encryption
Permissions
Modes
Sticky bit
Interfaces
File manager
File system API
Installable File System
Virtual file system
Lists
Cryptographic
Default
Log-structured
v
t
e
Operating systems
General
Advocacy
Comparison
Forensic engineering
History
Hobbyist development
List
Timeline
Usage share
Kernel
Architectures
Exokernel
Hybrid
Microkernel
Monolithic
vkernel
Rump kernel
Unikernel
Components
Device driver
Loadable kernel module
Microkernel
User space
Process management
Concepts
Context switch
Interrupt
IPC
Process
Process control block
Real-time
Thread
Time-sharing
Scheduling algorithms
Computer multitasking
Fixed-priority preemptive
Multilevel feedback queue
Preemptive
Round-robin
Shortest job next
Memory management and resource protection
Bus error
General protection fault
Memory protection
Paging
Protection ring
Segmentation fault
Virtual memory
Storage access and file systems
Boot loader
Defragmentation
Device file
File attribute
Inode
Journal
Partition
Virtual file system
Virtual tape library
List
Acorn
Arthur
ARX
MOS
RISC iX
RISC OS
Amiga Inc.
AmigaOS
AmigaOS 1.0-3.9 (Motorola 68000)
AmigaOS 4 (PowerPC)
Amiga Unix, a.k.a. Amix
Amstrad
AMSDOS
Contiki
SymbOS
Android
Apple Inc.
Apple II family
Apple III
Apple DOS
Apple Lisa
Apple SOS
Apple Pascal
ProDOS
GS/OS
GNO/ME
Contiki
Apple Macintosh
Classic Mac OS
A/UX
Copland
MkLinux
Pink
Rhapsody
macOS (formerly Mac OS X and OS X)
macOS Server (formerly Mac OS X Server and OS X Server)
Apple Network Server
Apple MessagePad
Newton OS
iPhone and iPod Touch
iOS (formerly iPhone OS)
iPad
iPadOS
Apple Watch
watchOS
Apple TV
tvOS
Darwin
iPod
iPod software (unnamed embedded OS)
A/ROSE
Apollo Computer
Domain/OS
Atari
Atari DOS
Atari TOS
Atari MultiTOS
BAE Systems XTS-400
Be Inc.
BeOS
BeIA
BeOS r5.1d0
Bell Labs Non-Unix
BESYS
Plan 9 from Bell Labs
Inferno)
Burroughs Corporation
Burroughs MCP
BSD
Control Data Corporation
Chippewa Operating System
Kronos
NOS (Network Operating System)
SCOPE)
Convergent Technologies Operating System
Cosmos
Cromemco
Cromemco DOS
Cromix
Data General
AOS (for 16-bit)
DG/UX
RDOS (Real-time DOS)
Datapoint (CTOS for Z-80)
DDC-I Inc.
HeartOS
Digital Research, Inc.
CP/M
CP/M Plus
CP/M-68K
CP/M-8000
CP/M-86
CP/M-86 Plus
Concurrent CP/M
Concurrent CP/M-86
Concurrent CP/M 8-16
Concurrent CP/M-68K
Concurrent DOS
Concurrent PC DOS
Concurrent DOS 8-16
Concurrent DOS 286
Concurrent DOS XM
Concurrent DOS 386
Concurrent DOS 386/MGE
Concurrent DOS 68K
DR-DOS
FlexOS
FlexOS 186
FlexOS 286
FlexOS 68K
Multiuser DOS
Datapac Multiuser DOS
Datapac System Manager, a derivative of Datapac Multiuser DOS
IMS Multiuser DOS
MP/M
MP/M II
MP/M-86
MP/M 8-16
PalmDOS 1.0
Personal CP/M
Digital Equipment Corporation
Batch-11/DOS-11
OS/8
RSTS/E
RSX-11
RT-11
TOPS-10
TOPS-20
TENEX
Digital UNIX
Ultrix
VMS
WAITS
DOS
ENEA AB OSE
Fujitsu Towns OS
General Electric, Honeywell, Bull
Real-Time Multiprogramming Operating System
GCOS
Multics
Genode
GNU
Google
Android
Chromium OS
Chrome OS
Goobuntu
Fuchsia)
Green Hills Software
INTEGRITY
INTEGRITY-178B
µ-velOSity
Haiku
Harmony
Heathkit, Zenith Data Systems
HDOS
HT-11
Hewlett-Packare
HP-UX
Multi-Programming Executive
Honeywell CP-6
Huawei Harmony OS
Intel Corporation
ISIS
IBM
Pre-360
BESYS
CTSS
GM OS & GM-NAA I/O
IBSYS
SHARE Operating System
University of Michigan Executive System (UMES)
OS/360 and successors
OS/360 and successors
MVS
OS/390
Phoenix/MVS
z/OS)
DOS
DOS/360 and successors on IBM S/360, S/370, and successor mainframes
BOS/360
TOS/360
DOS/VS
DOS/VSE
VSE/SP
VSE/ESA
z/VSE)
VM/CMS
CP/CMS
CP-40
CP-67
VM/370
VM/XA
VM/ESA Virtual Machine
z/VM)
TPF line
Airline Control Program ACP
Transaction Processing Facility)
Unix-like
AIX
UTS (Mainframe UNIX)
Linux on z Systems
Others on IBM S/360, S/370, and successor mainframes
TSS/360
MUSIC/SP
ORVYL and WYLBUR
IBM PC
PC DOS
OS/2
OS/2 Warp
eComStation)
Other hardware
IBM Series 1
EDX
RPS
CPS
IBM 1130 DM2
IBM 1800 MPX & TSX
IBM 8100
DPCX
DPPX)
System 3 DMS
IBM System 34, 36, 38
OS/400
illumos
IncludeOS
iOS
audioOS
iPadOS
tvOS
Linux
MINIX
MorphOS
MUSIC/SP
Nemesis
NeXTSTEP
NOS
ORVYL
OS/2
OS-9
OSv
Pick
QNX
ReactOS
RISC OS
Solaris
Tandem
NonStop
TPF
TRIPOS
Unix
Visi On
VS/9
webOS
Windows
Xerox 500 series (530 RTB, 560)
Xinu
z/OS
Miscellaneous concepts
API
Computer network
HAL
Live CD
Live USB
OS shell
CLI
GUI
NUI
TUI
VUI
ZUI
PXE
0.00
(0 votes)
Original source: https://en.wikipedia.org/wiki/Procfs. Read more