IDENTIFY SYSTEM INFORMATION WITH /PROC

Linux has a virtual filesystem, known as /proc, that displays a variety of information about your computer. The /proc filesystem contains a number of files and directories, all of which correspond to process IDs for different programs. A number of programs, such as top and other monitoring tools, gather data from the /proc filesystem.

Use the following command to gain detailed information about your CPU:

$ cat /proc/cpuinfo

Suppose you have a program and want to know what environment was used when it was launched. Or perhaps you're debugging your CUPS print server and need to gather information about its environment. If so, use this command:

# ps ax|grep cupsd|grep -v grep
23660 ? S 0:09 cupsd
# cat /proc/23660/environ

The first part of the command obtains the process ID number for the cupsd process--in this case, PID 23660 and the second part accesses the environment that was used to start this process.

Contents of the environ file are identical to what would be displayed if you issued the env command as the user running that process. Keep in mind that to view this information you must be root, unless you're looking
at your own processes, because most users don't have permission to view information about other users' processes.

You can also use /proc to gain detailed information on memory statistics, such as how much memory is installed, how much swap is available, and how much memory and swap are being used. Here's how:

$ cat /proc/meminfo

While the /proc filesystem isn't something you want to dig around in every day, it's certainly useful if you wish to obtain specific information or write your own tools or scripts to gather statistics.