Mar
22
In this article I will talk about /proc which should be of interest to Linux newbies. I spent a couple of hours using “cat” to find system information. This is really slick. It’s much easier and much quicker than the wizards Windows uses. Just open a bash shell, su to root, and cd to /proc. If you do an ‘ls -la’ in the /proc directory, you’ll list out all the dynamic directories and fines in /proc. Then it’s a simple matter of using the cat command to list all the info in the appropriate directories or files. There is a ton of system info to be found.
The /proc filesystem is a direct reflection of the system kept in memory and represented in a hierarchal manner. The effort of the /proc filesystem is to provide an easy way to view kernel and information about currently running processes. As a result, some commands (ps for example) read /proc directly to get information about the state of the system. The premise behind /proc is to provide such information in a readable manner instead of having to invoke difficult to understand system calls.
The /proc fs can be used for system related tasks such as
- Viewing Statistical Information,
- Finding out HardwareInformation,
- Modifying Runtime Parameters,
- Viewing and Modifying Network Host Parameters
- Memory and Performance Information
Now with the definition out of the way, let’s start with the examples:
Print System Information
- cat /proc/cpuinfo - Information about the processor, such as its type, make, model, and performance.
- cat /proc/devices - List of device drivers configured into the currently running kernel.
- cat /proc/filesystems - Filesystems configured into the kernel.
- cat /proc/interrupts - Shows which interrupts are in use, and how many of each there have been.
- cat /proc/ioports - Which I/O ports are in use at the moment.
- cat /proc/meminfo - The number of total, used and free bytes of memory and swap area(s)
- cat /proc/loadavg - Average of system load for the last 1, 5 and 15 minutes
- cat /proc/uptime - Time in seconds since boot-up and total time used by processes
- cat /proc/version - Current rev of the kernel and/or distribution
- cat /proc/environ - The process environment variables
- cat /proc/mounts - Shows mounted filesystems. Shows device, mount point, filesystem type, permissions.
- cat /proc/pci - Current occupation of pci slots.
Writing To Proc Files
Some proc files can be used to adjust settings in the kernel. This is especially true for files in the /proc/sys/ subdirectory.
Some examples to change a setting temporarily on your system:
- echo abc > /proc/sys/kernel/hostname
This changes your server hostname to abc.example.com
- echo example.com > /proc/sys/kernel/domainname
This sets a domain name if you don’t have arleady or changes to a new one.
- echo Windows > /proc/sys/kernel/ostype
If you want to have some fun, you can change this to print Windows instead of Linux on your boot prompt
- echo “Version 0.0.1″ > /proc/sys/kernel/osrelease
Another neat trick to confuse your users.
There is a utility called sysctl - This tool is used to manipulate kernel parameters. If you type sysctl -a | more, you’ll see a long list of kernel parameters. You can use sysctl to modify these parameters. Only root has access to update.
This is Part 1 of /proc file system. There are many cool data /proc can provide to help troubleshoot or simply compile data about your server and operating system. In the next part of this article, I will explore a bit more advanced directories and kernel manipulation. I will also briefly touch on utilizing /proc fs as a programming tool.
WARNING: Be sure to avoid viewing the kcore file in /proc. This virtual file contains an image of the kernel’s memory, and the contents of the file will do strange things to your terminal. In general, do not view any file unless you’re sure what it does.
Comments
2 Comments so far







Nice post.
I’ve been using ubunu now for a couple of months as my work machine and im sure these tips will come in handy at some stage
very useful
also
cat /proc/partitions to show all partitions
cat /proc/scsi/scsi to show drives