7/29/2009 -- There exists in Linux a unique entity: /proc. While it appears in listings like a directory, /proc is actually a virtual filesystem (in reality, it's more a file system interface to the kernel, but that's delving too deep). Beneath this directory/filesystem, you can find temporary pseudo-files that are created by the running processes and can be used to identify what resources the system is using. Many utilities use what they find in /proc to gain information, and you can, too. The key is to understand what you're seeing.
Processes are depicted as directories, and each has permissions and variables associated with it. In contrast, standard system information is usually shown as files. As an example, the init process will always have a PID number of 1. Because of this, you can get a quick glance at the current state of the system by looking at /proc/1 with the command:
ls -l /proc/1
The following table summarizes some of the files in the /proc file system that provide information about your Linux system. You can view some of these files on your system to see what they contain, but note that not all of them may be present on your system. The specific contents of the /proc file system depend on the kernel configuration and the driver modules that are loaded (which, in turn, depend on your PC's hardware configuration).
File Name
|
Content
|
/proc/acpi
|
Information about Advanced Configuration and Power Interface (ACPI), an industry-standard interface for configuration and power management on laptops, desktops and servers.
|
/proc/bus
|
Directory with bus-specific information for each bus type, such as PCI.
|
/proc/cmdline
|
The command line used to start the Linux kernel (for example, ro root=LABEL=/ rhgb).
|
/proc/cpuinfo
|
Information about the CPU (the microprocessor).
|
/proc/devices
|
Available block and character devices in your system.
|
/proc/dma
|
Information about direct memory access (DMA) channels used.
|
/proc/driver/rtc
|
Information about the PC's real-time clock (RTC).
|
/proc/filesystems
|
List of supported file systems.
|
/proc/ide
|
Directory containing information about IDE devices.
|
/proc/interrupts
|
Information about interrupt request (IRQ) numbers and how they're used. This may not show all the interrupts configured on your system because it only shows the ones in use, and Linux does not begin using an IRQ until a driver is loaded.
|
/proc/ioports
|
Information about input/output (I/O) port addresses and how they're used.
|
/proc/kcore
|
Image of the physical memory. This will appear as a very large file.
|
/proc/kmsg
|
Kernel messages.
|
/proc/loadavg
|
Load average (average number of processes waiting to run in the last one, five and 15 minutes).
|
/proc/locks
|
Current kernel locks (used to ensure that multiple processes don't write to a file at the same time).
|
/proc/meminfo
|
Information about physical memory and swap-space usage.
|
/proc/misc
|
Miscellaneous information.
|
/proc/modules
|
List of loaded driver modules.
|
/proc/mounts
|
List of mounted file systems.
|
/proc/net
|
Directory with many subdirectories that contain information about networking.
|
/proc/partitions
|
List of partitions known to the Linux kernel.
|
/proc/pci
|
Information about PCI devices found on the system.
|
/proc/scsi
|
Directory with information about SCSI devices found on the system (present only if you have a SCSI device).
|
/proc/stat
|
Overall statistics about the system.
|
/proc/swaps
|
Information about the swap space and how much is used.
|
/proc/sys
|
Directory with information about the system. You can change kernel parameters by writing to files in this directory. (Properly using this method to tune system performance requires expertise.)
|
/proc/uptime
|
Information about how long the system has been up.
|
/proc/version
|
Kernel version number.
|
Some Examples
If you don't know what processor your computer has, type:
cat /proc/cpuinfo
To save a list of the processing running to a file that you can mail, use the command:
ps -ef > /tmp/proc.txt
To see file system types that are currently available to be used on your system, type:
cat /proc/filesystems
To turn on dynamic IP addressing, type:
echo 1 > /proc/sys/net/ipv4/ip_dynaddr
To turn on IP forwarding (temporarily), type:
echo 1 > /proc/sys/net/ipv4/ip_forward
You can see current system status from the information beneath /proc with this command:
procinfo
A Cousin: The sys Directory
Meet the sys directory, a virtual entity that's the mount-point for a sysfs filesystem used by 2.6-based Linux systems to provide information about the devices and interfaces attached to it. It's analogous to /proc in that /proc holds process information and /sys holds system information. By changing into the /sys/bus and sys/devices directories, you can find files that identify the entities connected with the system.
|