Inspect compile logs in dmesg
In the previous steps, you learned how to view the kernel configuration. Now, let's look at the kernel's message buffer, which contains messages produced by the kernel during boot and runtime. This can sometimes include information related to the kernel compilation or modules being loaded.
The dmesg
command is used to examine or control the kernel ring buffer. The ring buffer stores messages from the kernel, which are often useful for debugging and understanding system events.
Type the following command in your terminal and press Enter:
dmesg
This will print a large amount of output to your terminal. These are messages from the kernel, including information about hardware detection, device drivers being loaded, and other system events that occurred since the system booted.
To find information related to the kernel version or compilation, you can pipe the output of dmesg
to grep
. grep
is a powerful command-line utility for searching plain-text data sets for lines that match a regular expression.
Let's search for lines containing the word "Linux" to see the kernel version information.
dmesg | grep "Linux"
You should see output similar to this, showing the kernel version:
[ 0.000000] Linux version 5.15.0-105-generic (...)
You can also search for other keywords that might be related to kernel modules or compilation options, although direct compilation logs are usually not found here. dmesg
is more about runtime kernel messages.
For example, you could search for messages related to a specific driver or subsystem if you know its name.
Again, using less
with dmesg
is helpful for navigating the output:
dmesg | less
Press q
to exit less
.
While dmesg
doesn't directly show the kernel compilation process itself, it provides valuable insights into the kernel that is currently running, including its version and loaded modules, which are determined by the compilation configuration you viewed in the previous steps.
Click Continue to complete this lab.