Proc file system (short for βprocfsβ, referring to β/proc
β dir) is a virtual file system (not a real file system) that is mounted on system boot to store information related to running processes.
The proc file system stores useful information about the running process and also lets the kernel space and user space communicate with each other.
When you list the content of the β/proc
β directory using the ls command, you will get a bunch of directories, and their names will be in integer format, where βintegerβ refers to a process identifier.
$ ls -l /proc
Output:
Within the same directory, you will find the βmeminfo
β, βcpuinfo
β, βdevices
β, βfilesystems
β, etc. files that contain system related information.
Execute the following command to get the complete list of system information files:
$ ls -p /proc/ | grep -v /
Output:
Here is a list of the known system information files with their descriptions in the β/proc
β directory.
System Information File | Description |
---|---|
/proc/crypto | List of available cryptographic modules. |
/proc/cmdline | Kernel command line information. |
/proc/consoles | Current console information (including tty). |
/proc/devices | Information related to device drivers currently configured for the running kernel. |
/proc/diskstats | Information (including device numbers) for each of the logical disk devices. |
/proc/dma | DMA channels information. |
/proc/fb | Frame buffer device information. |
/proc/filesystems | List of file systems supported by the kernel. |
/proc/iomem | Information related to the current system memory map for devices. |
/proc/ioports | I/O ports related information. |
/proc/kmsg | Holding messages output by the kernel. |
/proc/loadavg | Average system load. |
/proc/locks | List of files currently locked by the kernel. |
/proc/meminfo | Information about system memory. |
/proc/misc | Miscellaneous driver related information. |
/proc/modules | Information on the kernel modules that are currently loaded |
/proc/mounts | List of mounted devices on the system. |
/proc/partitions | Information about all available partitions on the system. |
/proc/pci | PCI device. |
/proc/stat | Display file and filesystem information. |
/proc/swap | Display the swap related information. |
/proc/uptime | Uptime information |
/proc/version | Kernel, GCC, and distribution related information |
Read the content of any of the above mentioned files (ex: βmeminfo
β) by using the cat command.
$ cat /proc/meminfo
Output:
As Iβve told you earlier, each directory inside β/proc
β is in integer format, where βintegerβ refers to a process identifier.
To find any process related information, first find its process identifier (or PID) using the ps command.
$ ps aux | grep gedit
Replace βgedit
β with your process name.
Use the PID from the above output to list the content of all files and links related to the referenced process.
$ ls /proc/32710/
Output:
The following is a list of each directory along with its description that resides in the process directory.
Directory | Description |
---|---|
/proc/PID/cmdline | Information about process command line arguments. |
/proc/PID/cpu | Information about the current and last CPU instance in which the process was executed. |
/proc/PID/cwd | Link to the processβs current working directory. |
/proc/PID/environ | Information about environmental variables inherited by the process. |
/proc/PID/exe | Link to the executable of the referenced process. |
/proc/PID/fd | List of all file descriptors under the process. |
/proc/PID/maps | Information about memory maps to executable and library files. |
/proc/PID/mem | Information about memory held by the referenced process. |
/proc/PID/root | Link to the referenced processβs root directory. |
/proc/PID/stat | Process status. |
/proc/PID/statm | Process memory status information. |
/proc/PID/status | Process status in human readable form. |
To get the list of file descriptors under the running process, issue the following command:
$ ls -l /proc/32710/fd
Output:
To output the current working directory of the running process, issue the following command:
$ ls -l /proc/32710/cwd
Output:
This way, you can list and check various information related to the referenced process.
Final Tips!
The proc file system is a crucial part of Linux computing, and using it, you can check a bunch of information about specific processes or system information.
If you have any questions or queries related to this topic, then feel free to ask them in the comment section.
Great content! Super high-quality! Keep it up!