This time around, as a part of our long-running series on obscure Linux topics that wizards should know, we’ll wrap up the discussion of Linux processes with a look into the twisty (virtual) corners of the /proc pseudo-filesystem. This little-known directory is a gold mine of information about your system and its processes.
If you typically call utilities like uptime or ps to get system information from scripts, you may start using /proc from now on: your script can read /proc without invoking a new process, so it can be more efficient. One warning, though: /proc isn’t necessarily the same on every Linux system, and non-Linux systems may not have it at all. If you use /proc in a script that should be portable to other systems, check the other systems — or stick to the old standby utilities like uptime.
Introducing /proc
If you haven’t looked in /proc before, that’s a good place to start. See Listing One.
Listing One: Top level of /proc directory
$ cd /proc $ ls -F 1/ dma self@ 10/ driver/ slabinfo 1043/ loadavg stat 11037/ locks swaps 11041/ meminfo sys/ 11042/ misc sysrq-trigger cmdline modules sysvipc/ cpuinfo mounts@ uptime crypto mtrr version devices partitions vmstat diskstats scsi/ zoneinfo
We won’t describe every part of /proc here; doing that would fill most of this article’s three pages! (And, to save space, we’ve omitted a lot of the entries from Listing One.) You can get details from the proc manual…
Please log in to view this content.
Not Yet a Member?
Register with LinuxMagazine.com and get free access to the entire archive, including: