In this video, you'll learn about the directories dev, sys, and proc, pseudo-file systems that
help you in tracing what is going on in hardware and kernel-related events.
So what is going on in these pseudo-file systems?
Well, they exist in memory only and not on disk, and they are used by the kernel to keep
track of what is happening on your system.
Slash proc is for kernel runtime information and tunables.
You can get a lot of information out of slash proc, and you can also tweak your kernel by
changing parameters in the slash proc directory.
Slash sys is used for hardware-related information.
And slash dev is used to create the device nodes.
Let's have a quick look so that you understand what is going on.
So when we use mount, pipe, grab, proc, there you can see that this magical mount proc on
slash proc type proc, so proc, proc, proc is mounted.
So the device, it's not really a device, it's a kernel interface proc, which is mounted
on the directory proc, and the type is proc.
And that makes this directory special, so special that different rules apply.
You cannot open the files in here in editors, but you can check what is going on for more
information.
Use, for instance, cat on CPU info to get information on your CPU.
Use cat on modules to get information about kernel modules that are currently loaded.
And in case you are thinking, hey, this sounds familiar, well, it sounds familiar because
lsmod is the user interface to the same information.
You should remember that slash proc sys were never created as an easy user interface.
As a user, you normally use tools to get information about what is going on in these file systems.
Apart from the status files that you see in black on the right in the file listing in
slash proc, there are PID files, these are the numbers to the left.
Every process has a PID file in which you can get process information.
And there is also proc sys, which can be used for kernel optimization.
As this section is about hardware and drivers, we are mainly interested in the status files
that you can see on the right.
Now let's talk about sys.
Sys is also one of these pseudo file systems.
So when I use mount pipe grab sys, we can see sysfs is mounted on slash sys, and the
type is sysfs.
So it's in memory, it's not on disk.
And here you find different interfaces that tell you what is going on.
For instance, there is sysmodule, and in sysmodule, you will find directories for all the different
modules that are used on your system.
Let's check out E1000E, for instance, which is the module that is used to address your
network.
So in this directory, we can see a parameters directory.
And in the parameters directory, look at that.
We have a copy break parameter, which is set to the value of 256.
Now what you find in the module directories is really dependent on the driver that is
involved.
Sometimes it's useful information.
Sometimes, as we've seen before for the CD-ROM module, it's rather disappointing.
Another one that I like is in sysbus.
We have CPU, and in CPU, you have devices.
And there you can see a CPU0 and a CPU1.
Right now, when I use lscpupipeless for restricting the output, I can see there are two CPUs.
Now when we use ls in CPU1, you can see that there is this online file.
And what is in this online file?
Well, let's check it out.
It has a 1.
You know what I'm going to do?
I'm going to echo 0 into CPU1 slash online.
This is a rule that applies for everything that you find in PROC and in sys.
You cannot open these cells in an editor.
If you want to change the content, you need to echo the new value into the file just the
way I'm doing it right here.
And what is the result?
Well, the result is that lscpu is now showing me two CPUs, but only one is online, and the
other one is offline.
That's cool, isn't it?
If temporarily, for whatever reason, you need to offline a CPU, this is how you can do it.
I'm onlining it again because I don't want it to be offline.
Final directory, you have probably already worked with it, is the dev directory.
The dev directory is where device nodes are created.
And these device nodes allow users to interface the devices on your system.
That is what is happening where you're mounting devices, for instance.