One of the greatest things about Linux is how much control you have over your system. You can edit whatever you want, and there’s so much that’s flexible and available to you. Additionally, Linux is very transparent – error messages are very clear, and it’s not hard to see the inner workings of your system. One of the best ways to see those inner workings is the “/proc” directory. Here we show you how to use the “/proc” directory to examine the inner workings of your Linux system.
What Is the /proc Directory?
The “/proc” directory is populated from scratch every time your Linux system boots and throughout the time that it’s running. The kernel takes a survey of all the hardware in the system and stores that information there, making it easy for other programs to look at detailed information on the system hardware.
Probably the most important thing to understand about “/proc” is that it’s not a normal directory with normal files – it’s more like a view into the system internals. Files in this directory are not read and saved to the hard drive like your average document or MP3 – they’re generated by the Linux kernel on the fly. Accessing the “/proc/meminfo” file will likely give you different results each time because memory usage is nearly always fluctuating.
By putting this kind of system information into a virtual filesystem like “/proc,” the developers adhere to the UNIX philosophy “everything is a file.” They do this so that it can be easily read by any person or software as easily as a normal text file – no special libraries or languages necessary. For us, this means that up-to-date system information is always easily available.
Note: the files mentioned here should all open cleanly in any text editor of your choice. The examples are showing the content using the standard
cat command from within a terminal.
If you’ve spent any time at all in “/proc,” there’s a good chance you’re familiar with this file. Displaying the contents of “/proc/cpuinfo” will give you a detailed picture of exactly what CPU you have and what features it supports.
The other well-known file in /proc, “meminfo,” is an extremely handy file to keep around. It shows you information about memory and swap usage and is one way that scripts and programs can find out what’s available.
This file shows the options that were used to start the kernel. This can be handy when troubleshooting boot problems or if you need to verify which kernel file was used for boot. You can also check if your Nouveau driver blacklist worked, which mine clearly did.
A lesser-known but still useful file is “filesystems.” From here you can read the (somewhat extensive) list of filesystems currently supported by your kernel. Not all of these are the type of filesystems you’d use to store your data – some are like “/proc” itself and have special-purpose uses.
In this case, PID is the process ID of a running program. Each process has a unique number that the system uses to identify that particular instance of that particular program. For example, when you run the program
top from the command line, you see a list of running processes and their PIDs. Each process has its own subdirectory in “/proc,” which you can browse for information about that particular process.
One of the most vital of the files in /proc, “modules” contains a complete list of the currently active kernel modules. If you’ve ever had to work through video driver issues, you likely know how useful this can be. While likely not something you’d use every day, this file can be a lifesaver for troubleshooting.
You can quickly and easily check all your mounted devices by opening the “mounts” file. Once again, many of the items here are not necessarily mounts points that a user needs be aware of. Most of the sections relevant to you will be found toward the bottom.
There’s certainly more to “/proc” than can be covered here, so I’d greatly encourage anyone reading this to do some poking around in “/proc” to find the bits of information that could be really useful to you. While many of the files you’ll find there are intended to be used by the OS itself, they can all provide a valuable look into Linux’s operations.
Now that you know how to examine the “/proc” directory, next you should find out how to use the Hosts file to access your local server and block ads and websites. You can also find out more about the virtual directory structure in Linux.
Our latest tutorials delivered straight to your inbox