Procfs
The proc filesystem 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 in the
kernel. It can be used to obtain information about the system and to change
certain kernel parameters at runtime.
Many Unix-like operating systems support the proc filesystem, including Solaris, IRIX, Tru64 UNIX, BSD, Linux, IBM AIX, QNX, and Plan 9 from Bell Labs. OpenBSD dropped support in version 5.7, released in May 2015.
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.
History
UNIX 8th Edition
implemented the UNIX 8th Edition version of /proc: he presented a paper titled 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 .SVR4
and Ron Gomes ported V8 /proc to SVR4, and published a paper called 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
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
cloned its implementation of from Plan 9., procfs is gradually becoming phased out in FreeBSD. 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".Solaris
/proc in Solaris was available from the beginning. Solaris 2.6 in 1996 introduced procfs2 from Roger Faulkner.Linux
Linux implementation includes a directory for each running process, including kernel 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 of the process.
- contains the names and values of the environment variables that affect the process.
- , a symlink to the original executable file, if it still exists.
- , a directory containing a symbolic link for each open file descriptor.
- , 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.
- , a binary image representing the process's virtual memory, can only be accessed by a ptrace'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 to any tasks that have been started by this process.
total 0
lrwx------ 1 baldur baldur 64 2011-03-18 12:31 0 -> /dev/pts/3
lrwx------ 1 baldur baldur 64 2011-03-18 12:31 1 -> /dev/pts/3
lrwx------ 1 baldur baldur 64 2011-03-18 12:31 2 -> /dev/pts/3
$ readlink /proc/$/exe # List executable used to launch the most recently started `python' process
/usr/bin/python3.1
)
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 :
- depending on the mode of power management, 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 input/PCI/USB. This has been largely superseded by sysfs 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 its speed, cache size, number of siblings, cores, and CPU flags. includes a value for "bogomips", frequently misconstrued as a measure of CPU speed, like a benchmark, but it does not actually measure any sensible 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.
"siblings" = *
"cpu cores" =
A CPU package means physical CPU which can have multiple cores.
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. 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 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 self-explanatory details about the devices using the various system resources
- , 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 of dependencies.
- , a symlink to self/mounts which contains a list of the currently mounted devices and their mount points.
- , a directory containing useful information about the network stack, in particular, which lists existing network connections
- , a list of the device-numbers, their size and names which the kernel has identified as existing partitions
- , giving information about any devices connected via a SCSI or RAID controller
- a symbolic link to the current process at .
- , 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 files.
- , containing memory-sharing and inter-process communication 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
- , containing the Linux kernel version, distribution number, gcc version number 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.