Javatpoint Logo
Javatpoint Logo

Linux proc

In Unix-like OSes, the proc is a unique filesystem that illustrates details about processes and details of other systems in a hierarchical file-like structure.

It is giving a more standardized and convenient mechanism to dynamically access process data held within the kernel as compared to the direct access to the kernel memory or the traditional tracing mechanisms or direct access.

It is typically mapped to the mount point referred to as /proc on boot time. A proc file system implements as an interface data structure within the kernel. It could be used for obtaining information about a system and for changing several kernel parameters on run time.

Various Unix-like OSes support a proc filesystem like Plan 9 from Bell Labs, IBM AIX, QNX, Linux, BSD, Tru64 Unix, IRIX, and Solaris. OpenBSD was published in May 2015 dropped its support in the 5.7 version.

The Linux kernel develops it to the non-process-related data.

A proc filesystem gives a communication method between user space and kernel space. For example, the GNU version of a process reposting utility ps applies a proc filesystem for obtaining the data without applying a specialized call.

History of proc filesystem

Linux proc

UNIX 8th Edition

Tom J. Killian achieved the proc UNIX 8th Edition (V8) version. In June 1984, he illustrated at USENIX paper entitled "Processes as Files". The proc filesystem design focused on replacing a system call, i.e., ptrace used to process trace.

SVR4

Ron Gomes and Roger Faulker ported V8 /proc version to SVR4 and released a paper at USENIX which is known as "The Process File System and Process Model In Unix System V" in January 1991. This type of proc filesystems supported the ps creation, but the files can only be used with some functions such as ioctl(), read(), and write().

Between 1995 year and 1996 year, Roger Faulker established the interface of the procfs-2 for the 2.6 version of Solaris that provides an organized /proc filesystem with many sub-directories.

4.4BSD

4.4BSD copied it's /proc implementation through Plan 9. Gradually, the procfs becoming phased out within FreeBSD as of February 2011. It was deleted in the 5.7 version from OpenBSD which was published in May 2015 as it "always suffered from many race conditions and now it is unused".

Plan 9

Plan 9 carried out a process file system. Although, it went further as compared to V8. The process file system of V8 carried out one file per process. This edition made /proc file which an original file system's part and it also made a hierarchy of isolated files for providing those functions.

Linux

In 1992, Linux initially added a /proc in v0.97.3, and first started developing it to the non-process related data in December 1992 in v0.98.6.

The implementation of Linux contains a directory for all the running processes as of 2020 including processes of the kernel, in directories called /proc/PID, in which PID is a number of the process.

All directories include details about a single process. Some of these directories are explained below:

  • /proc/PID cmdline: It is a command that began the process originally.
  • /proc/PID/cwd: It is a symlink to the working directory (current) of a process.
  • /proc/PID/exe: It is a symlink for a real executable file when it still available (a process might go on running after it real executable has been replaced or deleted).
  • /proc/PID/environ: It includes the values and names of many environment variables that impact a process.
  • /proc/PID/fdinfo: It is a directory including entries that specify the flags and position for all open file descriptors.
  • /proc/PID/fd: It is a directory including a symbolic link for every open file descriptor.
  • /proc/PID/maps: It is a text file including details about mapped blocks and files (such as stack and heap).
  • /proc/PID/root: It is a symlink to a root path as checked by a process. It is a link to the / directory for most of the processes unless a process is executing in a chroot jail.
  • /proc/PID/mem: It is an image (binary) repressing the virtual memory of the process. It can only be used by the ptrace'ing process.
  • /proc/PID/status: It includes common details about the process and its memory usage and run the state.
  • /proc/PID/task: It is a directory including hard links to the actions that have been begun by this process, i.e., parent.

Non-process-related system information of /proc

Also, the /proc file contains non-process-related information about the system. However, much of the information moved to an isolated sysfs, pseudo-file system, mounted under /sys in the 2.6 version of the kernel:

Either /proc/apm or /proc/acpi directory is relying on the power management mode which anticipates sysfs and includes several information bits about the power management state.

  • /proc/bus: It contains directories illustrating several buses on the system like USB/PCI. It has been superseded by the sysfs filesystem upon /sys/bus file which is more informative.
  • /proc/buddyinfo: It gives details about the buddy algorithm. This algorithm manages the memory fragmentation.
  • /proc/cmdline: It gives many options to boot which will pass to the kernel.
  • /proc/fb: It defines a list of existed frame buffers.
  • /proc/cpuinfo: It contains CPU information like the vendor (family of CPU, model and model names which should permit users for identifying the CPU), speed (CPU clockspeed), CPU flags, cores, number of siblings, and cache size.

This directory includes the "bogomips" value that is rapidly misconstrued as the CPU speed measure such as a benchmark. However, it doesn't measure a sensible value for end-users at all. It appears as a kernel timer calibration side effect and highly yields changing values relying on the type of CPU at the same clock speed.

CPU Package

A CPU package indicates a physical CPU that could have more than one core (quad-core for four, dual-core for two, one core for one). It permits a difference between dual-core and hyper-threading that is the one hyper-threading per CPU package could be measured by CPU or siblings core, if both the values for any CPU package are equal, hyper-threading will not be supported.

For example, a CPU package along with cpu cores=2 and siblings=2 is a dual-core CPU but doesn't support the hyper-threading process.

  • /proc/crypto: It defines a list of existing cryptographic modules.
  • /proc/diskstats: It gives some details (as well as device numbers) for all logical disk devices.
  • /proc/devices: It defines a list of block and character devices that are sorted by a device ID. Although, it is providing a large part of a /dev name as well.
  • /proc/interrupts: Some directories like /proc/interrupts, /proc/irq, /proc/ioports, and /proc/iomem providing information of the devices (logical or physical) with several system resources.
  • /proc/filesystems: It defines a list of file systems that are supported via the kernel during the listing.
  • /proc/meminfo: It contains an abstract of how the kernel is handling its memory.
  • /proc/kmsg: It holds messages result via the kernel.
  • /proc/mounts: It is a symlink to mounts/self which includes a list of the mounted devices (currently) and mount points as well.
  • /proc/modules: It is one of the necessary files in the /proc file system. It contains a list of kernel modules loaded currently. It provides a few dependency indications (not always correct entirely).
  • /proc/scsi: It gives information about a device that is connected via a RAID or SCSI controller.
  • /proc/partitions: It represents a list of the device size, /dev names, and their number which the kernel has recognized as available partitions.
  • /proc/slabinfo: It lists the statistics over the cache for regularly used objects within the Linux kernel.
  • /proc/sysvipc: It contains inter-process communication and memory sharing information.
  • /proc/uptime: It represents the time length in which the kernel has been executing since boot and utilized in an idle mode.
  • /proc/version: It includes the version of the Linux kernel, gcc version number (used for building the kernel), distribution number, and other pertinent details corresponding to the kernel version currently running.
  • All other files are depending on module configuration, many hardware, and modifications to the kernel.
  • The common utilities that apply /proc filesystem upon Linux fall in the /proc processes (procps) package.

Solaris

In Solaris, the /proc file was present from the starting. The 2.6 version of Solaris was announced /proc2 by Roger Faulker in 1996.

Proprietary Development

Various projects and companies added many additional functions to the /proc filesystem for their system. For example, the file /proc/lcd may contain the front-panel LCD screen contents. The text mentioned in this file will be shown on the screen.


Next TopicLinux Task Manager





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA