+5 votes
53 views
PROC Linux Directory

in Linux/Unix by (552k points)
reopened | 53 views

1 Answer

+3 votes
Best answer

How to use proc in Linux

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

 

Step 1

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:
 ls /proc 
image

 

Step 2

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”:

 

image

 

Step 3

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.

 

Step 4

To see this, we can, for example, access memory details by running the following:
 cat /proc/meminfo 
image

 

Step 5

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:
 cat /proc/cmdline 
image

 

Step 6

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:
 cat /proc/filesystems 
Step 7

There we will see the general list of the file systems that we can use in the distribution.

 

 

image

 

Step 8

Another function that proc allows us is to have access to the current system partitions, to do this we execute the following:
 cat /proc/partitions 
Step 9

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.

 

 

image

 

Step 10

Now, to view the version of the currently running kernel, we are going to use the command:
 cat /proc/version 
image

 

In this result we see the content of files like:

 

  • /proc/sys/kernel/ostype
  • /proc/sys/kernel/osrelease
  • /proc/sys/kernel/version

 

Step 11

To access disk I/O statistics for each available device, we run the command:
 cat /proc/diskstats 
image

 

Step 12

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.
 cat /proc/cpuinfo 
We see all the details of the CPU used in Linux.
image

 

Step 13

To access the system uptime, we are going to run the command:
 cat /proc/uptime 
image

 

Step 14

Proc allows us to access virtual memory statistics, to do this we use the command:
 cat /proc/vmstat 
image

 

Step 15

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:
 cat /proc/zoneinfo 
image

 

Step 16

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. :

 

image

 

Step 17

Within this file, we can access precise information, for example, we can see input and output (i/o) details:
 sudo cat /proc/PID/io 
image

 

Step 18

We can apply a limited amount of results in the console, for example we execute:
 sudo cat /proc/PID/fdinfo/3 
image

 

Step 19

Or we can see the status of that PID in real time:
 sudo cat /proc/PID/status 
image

 

This is how we can access very specific details of Linux using proc, it is ideal for numerous administrative tasks.

 


by (3.5m points)
edited

Related questions

+5 votes
1 answer
asked Oct 19, 2022 in Linux/Unix by backtothefuture (552k points) | 83 views
+4 votes
1 answer
+4 votes
1 answer
+4 votes
1 answer
asked May 22, 2019 in Linux / Unix by backtothefuture (552k points) | 255 views
+5 votes
1 answer
asked Oct 13, 2023 in Linux/Unix by backtothefuture (552k points) | 59 views
Sponsored articles cost $40 per post. You can contact us via Feedback

Most popular questions within the last 30 days

10,659 questions
10,791 answers
510 comments
3 users