In this lesson,
you're going to learn to leverage Linux's modular nature
in order to monitor system processes
and determine if it's operating properly.
You're also going to learn the tools available
for you to be able to monitor kernel modules
and perform fixed operations
without having the overall system impacted.
The first thing we're going to talk about
is the /proc directory,
which is a virtual file system or VFS.
The /proc directory provides significant information
about the kernel's running processes.
Now there are various files in the /proc directory.
We're only going to cover a couple of key ones.
First, let's talk about /proc/cmdline
or /cmdline.
This is a file that contains options passed to the kernel
by the boot loader
when you boot up the system.
This includes things like mounting the kernel as read only,
and things like that.
We also have /proc/cpuinfo.
This is a file that contains CPU information,
such as its architecture, its name,
its clock speed, its cache size,
and more things like that.
We also have /proc/devices.
This is a file that contains a list
of all the character and block device drivers
that are loaded into the currently running kernel.
We also have /proc/filesystems
which is going to have a file
that contains a list of all the file system types
that are being supported by this kernel,
as well as which ones are currently mounted.
If you want to learn about your memory,
you can look at /proc/meminfo.
This is a file that contains information
about your RAM usage,
including your total memory, your free memory,
and so much more.
If you look at the /proc/modules file,
this contains information
about the modules that are currently installed
on the system.
And if you look at the /proc/stat file,
this contains various statistics about the system
since it was last rebooted.
Now depending on the version of the kernel you're using,
you could have impacts to your system functionality.
So it's important to have a file
to validate the version you're using.
To look at this,
you can use /proc/version.
And when you look at that file,
it's going to specify several points of information
about the Linux kernel,
including the version of the Linux kernel
that's currently running,
the version of the GNU Compiler Collection or GCC
that's used to compile that kernel,
the username of the kernel compiler,
and the time the kernel was last compiled.
If you use the dmesg command,
this stands for display message or driver message,
and the dmesg command is used to print any messages
that have been sent to the kernel's message buffer
during or after the system boot.
Device drivers send messages to the kernel all the time
indicating the status of modules and parameters
that the drivers are interacting with.
These drivers can also send diagnostic messages
to the kernel
in case they have any kind of errors.
You can leverage the dmesg command
to look for potential issues with the kernel components
or to validate that certain modules
are actually loaded.
To run the dmesg command,
type in dmesg with whatever options you want.
Now, there's various options for this command
and to see them all,
look at the man pages.
But I'm going to cover a few of them here.
The option -c is going to be used to clear the kernel buffer
after printing its contents.
The option -f and a facility list
is going to be used to restrict output
to a specified comma-separated list of facilities.
A facility is essentially a component category
that's producing messages,
such as user for user level messages.
The option -l with a level list
is used to restrict output
to a specified comma-separated list of levels.
Now I talk about a level,
this defines a message's nature and priority,
such as a notice for messages
that aren't considered critical.
Option -e is going to be used to display
a human-readable version of the time
for each message as well as its delta
or the difference in time between subsequent messages,
option -L is used to color-code messages
for easier readability,
and option -H is used to output in a human-friendly format.
This combines both the -e and the -L options
using a text pager.
Finally, option -h is used to list the available options
as well as the available facilities and levels,
and it gives you some basic help options
for this particular command.
As I said,
there's a lot of other options with dmesg,
and we just barely scratch the surface.
So I do recommend playing with it a little bit
and looking at the man pages as well
so you can get more familiar with it
because it is useful in the real world
when troubleshooting issues.