To stay up to date, remember to subscribe to our YouTube channel!
SUBSCRIBE ON YOUTUBE
When working on Linux distributions, it is normal to find a series of commands that will help us manage the system in a much more comprehensive way and one of these commands is proc. The proc command in Linux is used to query information about processes in the system. With it you can show details such as the process ID, status and resources used. Viewing Proc files Linux is quite useful for monitoring and managing processes in real time, that is why we want to show you different examples to be able to use it with different syntaxes..
The proc command, which is a file system, allows us as users to have access to the kernel data structures and runtime information of the Linux distribution in which we are working. By having access to this information we will see in detail everything associated with the processes, system configuration, hardware, memory and more complete details.
Proc manages a wide group of options to use in Linux and TechnoWikis will explain to you in a global way how to use proc to have access to specific details..
How to use proc in Linux
It is possible to access a complete list of files and directories in the /proc file system, to do this we will use the following command:
As we see, we have access to all the available PIDs as well as the various files where the information of each parameter is housed, to access all of these, using the “cd” command we go to proc and then we list the content with “ls”:
In these files we find information about the system, we see aspects such as memory (meminfo), CPU information (cpuinfo) and available file systems, some of these directories are:
- /proc/cpuinfo: in it we find information about the system's CPU with details such as the model, speed and the number of available cores.
- /proc/loadavg: Allows you to view the system load average using time intervals in minutes.
- /proc/meminfo - Lists memory usage details and global statistics for everything related to RAM.
- /proc/sys: Allows you to view the configuration and runtime parameters of the Linux kernel.
- /proc/uptime: allows us to see the amount of time the system has been up.
- /proc/filesystems - Finds the list of all file systems supported by the core of the distribution.
To see this, we can, for example, access memory details by running the following:
We see in detail each aspect of the used and available memory, now, if we want to see the information from the kernel command line, we execute the following command:
We see in this line the entire technical aspect of the command line. To view the Linux-compatible file system, we are going to execute the following:
There we will see the general list of the file systems that we can use in the distribution.
Another function that proc allows us is to have access to the current system partitions, to do this we execute the following:
We find the largest and smallest numbers of each partition and we can also see the number of 1024-byte blocks and the partition name.
Now, to view the version of the currently running kernel, we are going to use the command:
In this result we see the content of files like:
To access disk I/O statistics for each available device, we run the command:
Another key command is to have access to CPU details, with the command below, we can see the set of elements dependent on the system and CPU architecture, this applies to each supported architecture in a different list, we execute the following.
We see all the details of the CPU used in Linux.
To access the system uptime, we are going to run the command:
Proc allows us to access virtual memory statistics, to do this we use the command:
Another option to use is to see the information of the memory areas, with this result it will be possible to analyze the behavior of the virtual memory, we can use the command:
As we saw, the directory numbers are related to the PID within the system, so it will be possible to directly access the PID to have its information available. With the “cd” command we access the PID and with the “ls” command we list its contents. :
Within this file, we can access precise information, for example, we can see input and output (i/o) details:
sudo cat /proc/PID/io
We can apply a limited amount of results in the console, for example we execute:
sudo cat /proc/PID/fdinfo/3
Or we can see the status of that PID in real time:
sudo cat /proc/PID/status
This is how we can access very specific details of Linux using proc, it is ideal for numerous administrative tasks.