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.