Today, we will delve into the contents of the /proc directory to develop a better understanding of its functionalities. Itβs important to note that the /proc directory is a common feature across all Linux distributions, irrespective of their flavor or architecture.
One misconception that we must immediately clarify is that the /proc directory is NOT a conventional file system in the traditional sense of the term.
It is a virtual file system that contains information about processes and other system-related data within the procfs. This file system is mapped to the /proc directory and is mounted during the systemβs boot process.
[ez-toc]
What is /proc in Linux
The /proc file system serves as an interface to kernel data structures and runtime information, which provides a way for both users and applications to access detailed information about processes, system configuration, hardware, and more, by exposing this data through a hierarchy of virtual files.
To view a complete list of files and directories in the /proc file system, you can use the ls command as shown.
$ ls /proc
Navigating /proc in Linux
When you navigate to the /proc directory, you will notice that there are some familiar-sounding files, and then a whole bunch of numbered directories, each corresponding to a running process on the system.
$ cd /proc $ ls
These numbered directories represent the processes, better known as process IDs (PIDs), and within them, a command that occupies them. The files contain system information such as memory (meminfo), CPU information (cpuinfo), and available filesystems.
Here are a few key files and directories youβll encounter:
/proc/cpuinfoβ List information about the CPU(s) on the system, such as the model, speed, and number of cores../proc/meminfoβ List details about memory usage and statistics that contain the total amount of memory, free memory, and the memory used by each process./proc/filesystemsβ Contains a list of all the filesystems that are supported by the kernel./proc/sysβ List configuration and runtime parameters for the kernel./proc/loadavgβ Show system load average over different time intervals such as 1, 5, and 15 minutes./proc/selfβ A symbolic link to the processβs own directory./proc/statβ Contains a variety of statistics about the system, such as the number of processes running, the number of interrupts, and the amount of time spent in each CPU state./proc/uptimeβ Contains the amount of time the system has been running./proc/PIDβ Contains information about a specific process, where PID is the process ID.
Extracting System Information
The /proc/meminfo is used to show information about the memory usage and statistics of a Linux system, which contains a snapshot of various memory-related metrics, which can be useful for monitoring system performance and resource utilization.
$ cat /proc/meminfo
As you can see, /proc/meminfo contains a bunch of information about your systemβs memory, including the total amount available (in kb) and the amount free on the top two lines.
Running the cat command on any of the files in /proc will output their contents. Information about any files is available in the man page by running:
$ man 5 /proc/<filename>
I will give you a quick rundown on /procβs files:
- /proc/cmdline β Kernel command line information.
- /proc/console β Information about current consoles including tty.
- /proc/devices β Device drivers currently configured for the running kernel.
- /proc/dma β Info about current DMA channels.
- /proc/fb β Framebuffer devices.
- /proc/filesystems β Current filesystems supported by the kernel.
- /proc/iomem β Current system memory map for devices.
- /proc/ioports β Registered port regions for input-output communication with the device.
- /proc/loadavg β System load average.
- /proc/locks β Files currently locked by kernel.
- /proc/meminfo β Info about system memory (see above example).
- /proc/misc β Miscellaneous drivers registered for the miscellaneous major devices.
- /proc/modules β Currently loaded kernel modules.
- /proc/mounts β List of all mounts in use by the system.
- /proc/partitions β Detailed info about partitions available to the system.
- /proc/pci β Information about every PCI device.
- /proc/stat β Record or various statistics kept from the last reboot.
- /proc/swap β Information about swap space.
- /proc/uptime β Uptime information (in seconds).
- /proc/version β Kernel version, gcc version, and Linux distribution installed.
Extracting Process Information
Within /procβs numbered directories you will find a few files and links. Remember that these directoriesβ numbers correlate to the PID of the command being run within them.
For example, navigating to /proc/<PID> provides details such as:
/proc/<PID>/cmdlineβ Command-line arguments used to start the process./proc/<PID>/statusβ Detailed status information, including memory usage and process statistics./proc/<PID>/fdβ Symbolic links to files opened by the process.
Letβs use an example to view a folder called /proc/12.
$ cd /proc/12 $ ls
If I run:
$ cat /proc/12/status
I get the following:
So, what does this mean? Well, the important part is at the top. We can see from the status file that this process belongs to rcu_tasks_rude_kthread. Its current state is idle, and its process ID is 12, obviously.
We also can see who is running this, as UID and GID are 0, indicating that this process belongs to the root user.
In any numbered directory, you will have a similar file structure, and the most important ones with their descriptions, are as follows:
- cmdline β command line of the process
- environ β environmental variables
- fd β file descriptors
- limits β contains information about the limits of the process
- mounts β related information
You will also notice several links in the numbered directory:
- cwd β a link to the current working directory of the process
- exe β link to the executable of the process
- root β link to the work directory of the process
This should get you started with familiarizing yourself with the /proc directory. It should also provide insight into how a number of commands obtain their info, such as uptime, lsof, mount, and ps, just to name a few.
If this article helped you solve a problem, consider buying a coffee. It helps keep TecMint free, supports the authors, and keeps the project going.

Got Something to Say? Join the Discussion... Cancel reply