/proc file system

The /proc file system
proc file system isn’t associated with a hardware device such as a disk drive. Instead, /proc is a window into the running Linux kernel. Files in the /proc file system don’t correspond to actual files on a physical device. Instead, they are magic objects that behave like files but provide access to parameters, data structures, and statistics in the kernel.The contents of these files are not always fixed blocks of data, as ordinary file contents are. Instead, they are generated on the fly by the Linux kernel when you read from the file. /proc file system contains a directory entry for each process running on the system.The name of each directory is the process ID of the corresponding process. These directories appear and disappear dynamically as processes start and terminate on the system.Each directory contains several entries providing access to information about the running process.Each process directory contains following entries

* cmdline contains the argument list for the process.
* cwd is a symbolic link that points to the current working directory of the process (as set, for instance, with the chdir call)
* environ contains the process’s environment.
* exe is a symbolic link that points to the executable image running in the process.
* fd is a subdirectory that contains entries for the file descriptors opened by the process.
* maps displays information about files mapped into the process’s address.
* root is a symbolic link to the root directory for this process. Usually, this is a symbolic link to /, the system root directory.The root directory for a process can be changed using the chroot call or the chroot command.
* stat contains lots of status and statistical information about the process.These are the same data as presented in the status entry, but in raw numerical format,all on a single line.
* statm contains information about the memory used by the process.
* status contains lots of status and statistical information about the process,formatted to be comprehensible by humans.
* The cpu entry appears only on SMP Linux kernels. It contains a breakdown of process time (user and system) by CPU

Few additional files under /proc file system
1. cat /proc/version
Display’s information regarding kernel version number, version of the compiler used to compile the kernel and user who compiled it.
Note the the size of file /proc/version is zero and also modification time of the file is always the current time.
2. OS name and kernel version and revision, are available in separate /proc entries as well.These are /proc/sys/kernel/ostype, /proc/sys/kernel/osrelease, and /proc/sys/kernel/version, respectively.
3. cat /proc/cpuinfo
Display’s information about system CPU (or CPUs, for a multiprocessor machine).
4. The /proc/sys/kernel/hostname and /proc/sys/kernel/domainname entries contain the computer’s hostname and domain name, respectively.This information is the same as that returned by the uname system call
5. The /proc/meminfo entry contains information about the system’s memory usage. Information is presented both for physical memory and for swap space.
6. The /proc/filesystems entry displays the file system types known to the kernel. The contents of /proc/filesystems list only file system types that either are statically linked into the kernel or are currently loaded.Other file system types may be available on the system as modules but might not be loaded yet.
7. The /proc/mounts file provides a summary of mounted file systems. Each line corresponds to a single mount descriptor and lists the mounted device, the mount point, and other information.
8. The /proc/locks entry describes all the file locks currently outstanding in the system.
9. The /proc/loadavg file contains information about the system load
10. The /proc/uptime file contains the length of time since the system was booted, as well as the amount of time since then that the system has been idle

Advanced Linux Programming
Mark Mitchell, Jeffrey Oldham, and Alex Samuel

This entry was posted in Unix and Unix Internals. Bookmark the permalink.

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