## Monday, July 12, 2010

### /proc/: The linux kernels live state

/proc/ is a virtual (ie in memory) part of the linux file-system that displays the current status and configuration of the kernel.

The amount of information about the system in this area is amazing.

For example try out these commands
cat /proc/cpuinfo
cat /proc/meminfo
cat /proc/version
cat /proc/uptime
cat /proc/net/dev


When scripting you will probably want to use the info in a more digested form. The command for a script could be something like

cat cpuinfo  | grep vend |  cut -d' ' -f2


A useful debug trick is to determine what the environment settings where for a process after it has been started. To do so you would cat the processes environ file like so;

cat /proc/<process_id>/environ


The /proc/sys directory can also be used to alter certain files in a live system to adjust the kernel system wide. To tell which files can be altered just ls -al and look for the writable bit. Keep in mind that changes made in the area are temporary, and some changes can easily kill the system. To make the changes permanent the /etc/sysctl.conf needs to be edited.

Refer to
http://www.linuxjournal.com/article/8381

http://linuxhelp.blogspot.com/2005/04/proc-filesystem.html