The /proc file system

The /proc is a special file system in Linux that contains extensive information about the system hardware. In some cases it controls low-level hardware devices.

The /proc file system is a pseudo file system and not a real file system. Except for a few, almost all files here are write-protected.

Warning, the /proc directory contains many files that require a deep understanding before you can play around with them. Do not attempt to modify the files here unless you know what you are doing or you will end up with an inoperable system. In the worst case, you could lose your Linux system installation.

What will we cover?

In this guide we will see an overview of the /proc file system. We see some selected subdirectories and files in this folder. Let’s start.

Using the /proc file system

Basically, the /proc file system is used to control the system hardware. It also gives the system’s hardware information, just like lspci, lsusb, lsmod, etc. In fact, it works with more hardware. This directory is an immense resource to gain knowledge about our computers.

Use cases for various proc subdirectories and files

As just described, proc contains large amounts of system information.

Let’s see some examples of /proc files and their subdirectories in action. We can use the cat, more or less commands to view the contents of different files:

1. /proc/scsi

The /proc/scsi subfolder contains data about SCSI devices and contains several subfolders and files. The main file of interest here is /proc/scsi/scsi. This file shows all standard SCSI devices:

$ Cat /perc/scsi/scsi

2. /proc/cpuinfo

The /proc/cpuinfo file contains the details of the CPU, such as model name, vendor ID, CPU cores, etc.:

$ Cat /perc/cpu info

3. /proc/version

The /proc/version file shows the Linux kernel version and other distribution-specific information:

$ Cat /perc/execution

Another tool that is similar to the /proc/version file in many ways is uname. However, the /proc/version file does not show some of the sophisticated hardware details provided by uname.

4. /proc/sys

The /proc/sys subdirectory is another important directory. In addition to providing system information, administrators can use it to directly influence the functions at kernel level. Therefore, the files in this directory should be used with care to avoid kernel instability.

4.1. /proc/sys/kernel

The /proc/sys/kernel is one of the important subfolders. The files contained here directly affect kernel operations. Let’s look at some files here:

domianname: Used to configure the domain name of the system

modprobe: Used to specify the location of the program that handles the loading of kernel modules

osrelease: Shows the version number of the kernel

$ Cat /perc/system/kernel/osrelease

ostype: Displays the operating system type for your system

$ Cat /perc/system/kernel/kind

4.2. /proc/sys/net/

The /proc/sys/net/ relates to network aspects. For example, it contains directories like ethernet/, ipv4/, ipv6/, etc. The files in these directories manage a system’s network configuration.

The /proc/sys/net/ipv4 directory contains many important files for managing network settings. Several of these settings work together to block attacks on a system and allow the system to act as a router.

These files should be treated with the utmost care. Otherwise, the remote connectivity of the system may be affected.

4.3 /proc/sys/vm

/proc/sys/vm helps to configure the Linux virtual memory (VM) subsystems. It contains various files like page cache, page cluster, overcomit_memory etc.

5. /proc/cmdline

The /proc/cmdline file shows the parameters passed to the kernel when it is initialized.

$ Cat /perc/command line

For example, look at this line from this file:

red root=/developer/hda2

The “ro” argument indicates that the kernel is mounted in read-only mode.

6. /proc/devices

The /proc/devices file lists various characters and block devices. These devices are the ones configured for use with the kernel. It excludes the devices whose modules are not loaded into the kernel.

$ Cat /perc/Devices

7. /proc/filesystem

The /proc/filesystems file lists all filesystems supported by the kernel. The first entry indicates whether the file system is mounted or unmounted. The other shows the name of the supported file system.

$ Cat /perc/file systems

8. /proc/meminfo

The /proc/meminfo file reports RAM usage in the current state. Various commands like top, ps and free use this file for their output.

$ Cat /perc/meminfo

9. /proc/modules

The /proc/modules file shows all modules loaded into the kernel. The first column is for the name of the module and the second is for the memory size of the module. The third column checks whether the module is loaded or not. Finally, the last column checks whether the module can automatically discharge itself.

10. /proc/stat

The /proc/stat file keeps logs of various system statistics since our last reboot. The entries in this file can be very long, like this:

$ Cat /perc/Stat

CPU 100007 739 321605 2239006 1504 0 8007 0 0 0

CPU0 213 0 287664 52897 3 0 0 0 0 0

CPU1 16327 228 4936 228482 208 0 7447 0 0 0

CPU2 13590 89 4493 327198 141 0 42 0 0 0

CPU3 13378 25 4398 327162 440 0 65 0 0 0

CPU4 17739 39 4340 323080 169 0 6 0 0 0

There are several important statistics, such as:

10.1. CPU

It calculates the number of jiffies for which the system is in user mode, low priority user mode, system mode, etc. The gross of all CPUs is measured and then listed by CPU.

10.2. side

It is the number of memory pages written and dumped to disk by the system.

10.3. To deceive

It is the number of swap pages that are being brought to disk and ejected by the system.

Conclusion

In this article we have given a general overview of the /proc file system in Linux. As you saw earlier in this article, the /proc file system contains a huge collection of system information; Therefore, it is impossible to fully cover it in this blog. However, you can also refer to man pages for insight into various other /proc utilities.

Related Posts