Linux Commands

Using Proc FileSystem In Linux

One of the most used simulated file systems in the Linux operating system is the Proc file system. This file system is generated on the fly when the system reboots and then destroyed when the system suspends. It serves as the kernel’s controller and knowledge center, containing valuable data regarding currently operating activities. The proc file system frequently serves as a conduit for communicating amongst kernel and Linux userspace. This guide will make you understand how to use the proc file system to check directories and folders in the Ubuntu Linux system.

Let’s get started. If you want to check the whole simulated proc directories using the Proc command in your Linux system, you can do it. Firstly, go to the activity bar and search for the command-line shell. Open it by tapping on it. You can also open it using the shortcut key “Ctrl+Alt+T”. When the command-line shell has been opened, now you can easily use the simple list command to list all simulated proc directories as below. You’ll see that every PID of a procedure has its dedicated repository if we list the folders. You will get a huge long list of directories and their users and privileges, as shown in the snap.

$ ls –l /proc

If you only want to list the proc directories using the proc command, you can execute the below query in the terminal. You can find that the output has been highlighted for directories only.

$ ls –l /proc | grep ‘^d’

In a Linux system, users can list all the currently running processes via the proc file system. So, try out the below “ps” command followed by the flag “-aux” to list all the running processes. The output shows the usernames, process IDs, percentage of CPU usage, memory usage, and a lot more.

$ ps -aux

Let’s check for any specific process using its process ID. So, try the below-stated list query along with the Process ID in it. The output shows that there is currently no entry for this process ID in the proc file system.

$ ls –ltr /proc/1704

The/proc directory contains a folder to every currently running task or process in the Linux Operating system, which comprises kernel procedures. Some of the directories in the proc file system /proc/PID are cmdline, mem, cpu, diskstats, cwd, filesystems, version, environ, exe, maps, root, stat, statm, and many more. If you want to get information regarding different things of Linux system via Proc file system, you can do so by navigating to a proc directory or without it. Firstly, we will see it by navigating to a proc directory using the simple “cd” command in the shell as below.

$ cd /proc

Now, as you have been navigated towards the proc directory, you can check more directories and their information. So let’s check for the memory information of a Linux system using the proc command. Try executing the below “cat” command to open the memory information folder. The output shows the data and details regarding memory usage, free memory, cached, buffers, and many more things.

$ cat /proc/meminfo

Let’s navigate to another subfolder, “12” in a proc directory using the “cd” command below.

$ cd /proc/12

Now we are in the “12” folder. You can list all the files and folders in it using the below list command.

$ ls

Now you can check any listed file from the below image using the cat command. Let’s look at the “stat” file to look within it using the below cat command followed by the path. The output is showing statistics regarding it.

$ cat /proc/12/stat

Let’s check the status of a file system using the below cat query in the shell along with the path of a proc file “status”. The output is showing different information regarding it.

$ cat /proc/12/status

Now we will have a look at different proc folders without navigating into a proc directory via the “cd” command. For this motive, we will be using the “less” command. Firstly, let’s have a look at the crypto folder to check information regarding it as below.

$ less /proc/crypto

The output in the snap below shows the details about the crypto folder, e.g., its name, driver, module, priority, type, size, and many more things. Press the “q” button to quit this window.

If any user wants to check the version of the currently working Linux system on their setup, they can try the below “less” command along with the path of the version folder via the proc file system.

$ less /proc/version

And the output below is showing the version of the Linux system and the Gcc compiler and GNU versions. Tap on the “q” key from the keyboard to come back to a terminal.

To check the memory information of a Linux operating system, try out the below “less” query in the shell, followed by the memory information folder path.

$ less /proc/meminfo

So, the output is showing us detailed data about the memory usage of the Linux operating system. It shows the total memory, free memory, available memory, buffers, cached, active, inactive memory, and any other information. Hit the “q” key from the keyboard to quit it.

Suppose somebody wants to check the information regarding disks and their statistics. In that case, they can easily utilize the underneath “less” query with the name of a folder mentioned as a path in the proc file system.

$ less /proc/diskstats

The following window will be opened quickly. You can see the statistics regarding the disks of the Ubuntu Linux system, their partitions, and loops. Hit the “q” button to come out from this window into the command terminal.

Conclusion:

In this guide, we have explained the proc file system in Ubuntu 20.04 system. I hope all the above-elaborated PROC file system commands and queries work for you.

About the author

Aqsa Yasin

I am a self-motivated information technology professional with a passion for writing. I am a technical writer and love to write for all Linux flavors and Windows.