Dig the mine /proc in GNU/LINUX

One of the most interesting directories on any GNU/Linux system is /proc, which is a virtual filesystem that
provides a lot of information on the hardware of the running system and of the various
processes running. This directory normally remains blank when system is off and loads all the info as the system starts.

In fact, many programs such as ps ,top ,free ,vmstat etc. act as frontend by obtaining  their information by mining  /proc .

Some well-known virtual files in /proc include ,whose contents can be well seen using cat ,

/proc/cpuinfo –  prints out information on therunning CPU(s)

/proc/meminfo –  prints out information on installed memory

/proc/cmdline – provides the arguments to the Linux kernel at boot.

/proc/apm – provides information related to Advanced Power Management, if installed(laptop)

/proc/loadavg – shows the system load average

/proc/filesystems – shows the available filesystem support in the kernel and whether or not  they are in use on a block device

/proc/mounts – show what mounts are currently active, what block device they belong  to, where they are mounted, and what options were used to mount them

/proc/net – A directory contains a no of  files,  related to network information

Also inside /proc,  few numbered directories are presnet .The numbers correspond to running processes. Inside each directory are a number of files that give   information regarding the process.

Lets say /proc/1/ would contain information on process #1, which is  the init process i.e. the parent of all processes .
Some files in this directory are symlinks; as the

/proc/1/cwd symlink points to /, which indicates  that init’s current working directory is /, the root directory.

/proc/1/exe symlink points to  /sbin/init, the program that is running.

/proc/1/cmdline is a file containing the command-line used to execute the program.

/proc/1/status file indicates the status of the program, which can be used to determine if a program is sleeping or a zombie process, the amount of memory it’s  using, the number of threads, the user/group privileges it is running etc.

So to determine what files are in use by a process, look in the /proc/[pid]/fd/ directory. Each link in
the directory will point to a file that is in use by the process in question.


About Divyashree - The GNULINUX Guy

I am a Linux and Opensource enthusiast. I started working on Linux early in 2007 while I was doing my Masters in Computer Science and passed out in 2010. Currently working as a DevOps in in Public/Private cloud domain. my @github : https://github.com/kumarprd my @nagiosexchange : https://exchange.nagios.org/directory/Owner/divyaimca/1 my @linkedin : https://www.linkedin.com/in/priyadarshee-kumar-☁-a9415615
This entry was posted in TIPS & T RICS. Bookmark the permalink.

One Response to Dig the mine /proc in GNU/LINUX

  1. manan says:

    nice post .

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s