Originally Published: Friday, 12 January 2001 Author: Tom Dominico, Jr.
Published to: enhance_articles_sysadmin/Sysadmin Page: 1/1 - [Printable]

Using the /proc Filesystem

Join Tom Dominico in exploring one of the corners of the Linux kernel, through your file system and the cat utility! Find out more about this valuable source of information.

   Page 1 of 1  

If you're like me, you enjoy poking around in your directory tree, hunting for interesting things. Perhaps you've noticed the /proc file-system, but haven't had much of a clue as to what it is used for. It contains a number of odd entries such as "meminfo", "kmsg", "interrupts", etc. If you've ever tried to do a "cat" on these files, you were probably greeted with a set of odd words and numbers that may not have made much sense at the time. However, for those who know how to use it, the /proc file system can be a valuable source of information about your Linux system.

The /proc file system is only a "virtual" file system. What this means is that none of the "files" that it contains are stored on your hard disk. Rather, it is a way to easily access dynamic information about your system at any time, and only exists in memory. Working with a Linux system sometimes requires a more in-depth knowledge of your system than other operating systems, such as, "what PCI devices do I currently have in my system? What interrupts are currently in use?" As you become more of a "power user", you'll find some of this information to be valuable as you perform certain tasks. Besides, isn't it just plain cool to have all this information at your fingertips? Imagine how impressed your friends will be as you rattle off the interrupts that are currently in use on your system! You'll be the life of the party for sure. (Well, at a LAN party, perhaps).

Examples

  • /proc/cpuinfo
    Information about the processor, such as type, make, and model. Here is a portion of what you might see:

    bash$ cat /proc/cpuinfo
    processor : 1
    vendor_id : GenuineIntel
    cpu family : 6
    model : 5
    model name : Pentium II (Deschutes)
    stepping : 2
    cpu MHz : 349.135
    cache size : 512 KB

  • /proc/devices
    A list of device drivers configured into the kernel.

  • /proc/interrupts
    A list of which interrupts are in use, and how many of each there have been. This can be very useful in diagnosing hardware conflicts, etc.

  • /proc/kmsg
    These are messages output by the kernel, which are also sent to syslog.

  • /proc/meminfo
    Provides information about memory on the system, including physical and swap. Here is a portion of what you would might see:

    bash$ cat /proc/meminfo
    MemTotal: 127920 kB
    MemFree: 3192 kB
    MemShared: 117728 kB
    Buffers: 2620 kB
    Cached: 21752 kB
    SwapTotal: 514072 kB
    SwapFree: 446336 kB

  • /proc/modules
    Tells which kernel modules are currently loaded.

  • /proc/net
    Within this directory is a lot of raw information about your system's networking, much of which is used by various networking utilities.

  • /proc/pci
    Lists PCI devices on the system, such as PCI network adapters, etc.

As you can see, there's a wealth of information to be found by looking in the /proc virtual file system. Some of it is human-readable, and some is used by various command-line utilities that format and present it in an easy-to-understand fashion. Sometimes these utilities may also add a little information of their own. For example, the command "uname -a" gets much of its information from /proc/version, while the "uptime" command provides information from both /proc/uptime and /proc/loadavg, as well as other sources. Don't be afraid to get your hands dirty and find out what each virtual file does - there are many that we didn't cover. The knowledge you gain will no doubt become valuable to you over time, whether you're a sysadmin or simply run your own box at home. So, the next time you're wondering, "What speed CPU is in this box?", don't reach for your system documentation - just head over to /proc.





   Page 1 of 1