Proc File System in Linux

I’d like to share an interesting finding with you today. Perhaps, many of you must be already familiar with it but being a newbie, it really intrigued me.

I have recently enrolled myself in the DevOps Ninja program conducted by my organisation- OpsTree. Everything that I’m learning here is new to me and often amuses me. One day, I was working on an assignment and executed the top command. I left the task as it is and meanwhile started browsing something on the internet. Suddenly a question struck my mind that from where the top command fetches its data ( you can see how I got digressed from my main assignment :p).

$ top

So, I started exploring (please make note of top command process ID here- 7564) and utilised lsof command to dig deeper.

$ lsof -p <process id>

Here, I happened to find /proc, went in and found a whole lot of process directories which contained a lot of useful information about system processes and its respective activity history.

WHAT’S /proc?

The /proc directory is present on all Linux systems, regardless of flavor or architecture. The /proc directory is NOT a real file system but a virtual file system that is created dynamically by Linux to provide access to certain types of hardware information and information about the running processes. It is mapped to /proc and mounted at boot time.

To display information about your CPU, you can use the cat /proc/cpuinfo command:

To display information about the file systems supported by currently running Linux kernel:, you can use the cat /proc/filesystems command:

To display statistics about memory usage on the system, use the cat /proc/meminfo command:

To display the Linux kernel version, distribution number and other kernel-related information, use the cat /proc/version command:

Within /proc’s numbered directories, you will find a few files and links. These directories’ numbers correlate to the PID of the command being run within them.

Let’s check what’s there inside in one of these numbered directories. Here, I chose 2016 and run cat status:

In any numbered directory, you will have a similar file structure. The most important ones, and their descriptions, are as follows:

  1. cmdline – contains the command that started the process
  2. environ – contains the names and content of the environment variables for the process
  3. fd – file descriptors
  4. limits – contains information about the limits of the process
  5. mounts – related information

You will also notice a number of links in the numbered directory:

  1. cwd – a link to the current working directory of the process
  2. exe – link to the executable of the process
  3. root – link to the work directory of the process 

Just like with the hardware information, you can display the content of these files using the cat command.

Blog Pundit: Kapendra Singh

Opstree is an End to End DevOps solution provider

Connect Us

2 thoughts on “Proc File System in Linux”

  1. “To display information about the file systems supported by the kernel, you can use the cat /proc/filesystems command:”
    This section seems partially correct it will be “list of the file systems supported by the kernel at the time of listing”. That means suppose in a RHEL/CentOS7 server we are not using xfs file system so the xfs will not populate while trigerring cat /proc/filesystems command although the kernel supports xfs, same as the case for nfs.

  2. Thank you Sourav for pointing it out. You’re right. I have updated it in the blog as well. The other file systems that are not listed is because their module is not installed yet. Once we do that, it gets listed /proc/filesystems too.

Leave a Reply