What does the /proc directory do?
Q When I issue a mount command, I see a filesystem called /proc that is not on my hard drive. Can you tell me what is it, and why is it there?
A On a typical Linux system, when you issue the mount command you will see at least two filesystems that don't appear to be accessible in the normal way. The first of these is the /proc filesystem, and the second will show as something like 'none on /dev/shm'. As you may know, /dev/shm is a filesystem that is used to manage virtual memory on your system, and doesn't create anything on your local disk. The /proc filesystem contains virtual files that are like a window into the current state of the running kernel. It does not occupy any space on the hard drive, and therefore is referred to as a virtual filesystem, but acts and looks like a disk-based filesystem. Viewing some of the files in /proc can give a great deal of information about your system. If you look at /proc/meminfo, you'll get a nice stack of information about the memory on your system:
# cat /proc/meminfo MemTotal: 515484 kB MemFree: 74656 kB Buffers: 5912 kB Cached: 352464 kB SwapCached: 12 kB Active: 126788 kB Inactive: 289772 kB
Looking at this information, you will see that not only does it tell you how much memory you have, including swap and real memory, but it tells you exactly what the current state of the memory is in terms of free space, and how it's allocated. Chances are that if you run this command again, some of the information will have changed, and this is generally the whole point behind /proc. It's like a snapshot of the current system state. The more advanced user can actually change the functionality of the kernel temporarily by editing the files in the /proc filesystem. For example, to turn on IP forwarding (to allow your system to act as a router passing network traffic arriving on one network interface out on another interface), you can issue the following command:
echo 1 > /proc/sys/net/ipv4/ip_forward
Do be aware, however, that this status is not permanent and will be lost at the next reboot. To make it permanent, you need to edit the /etc/sysctl.conf file to include the following:
net.ipv4.ip_forward = 1
To learn more about your system, have a root around in /proc. You can't break anything just by looking, and even if you do make a mistake and edit one of the /proc files accidentally, a quick reboot will wipe any changes you've made.
- What does the /proc directory do?
- Locked out of /home directory
- Hiding an Apache directory listing
- Mepis root directory not being mounted read-only
- Migrating a server's DNS, websites, home directory and email