Inspect boot logs with dmesg
In this final step, we'll look at the kernel ring buffer messages using the dmesg
command. The kernel ring buffer stores messages from the kernel, including information about hardware detection, device drivers, and system events that occur during the boot process.
The dmesg
command is used to display these messages. It's a crucial tool for diagnosing hardware issues or understanding what happened during system startup.
Open your terminal if it's not already open.
Type the following command and press Enter:
dmesg
This command will output a potentially very long list of messages. These messages are generated by the kernel as it initializes and interacts with the system's hardware and software.
You will see output similar to this (the exact output will vary greatly):
[ 0.000000] Linux version ... (buildd@lcy02-amd64-...) (gcc-...) #...-Ubuntu SMP ...
[ 0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-... root=UUID=... ro console=ttyS0,... quiet splash vt.handoff=7
[ 0.000000] KERNEL supported cpus:
[ 0.000000] Intel GenuineIntel
[ 0.000000] AMD AuthenticAMD
...
[ 1.234567] usbcore: registered new interface driver usbfs
[ 1.234567] usbcore: registered new interface driver hub
[ 1.234567] usbcore: registered new device driver usb
...
Notice that the output includes the kernel version and the command line arguments, similar to what we saw in /proc/cmdline
.
Since the output of dmesg
can be extensive, it's often useful to pipe it to a pager like less
or more
to view it screen by screen.
Try this command:
dmesg | less
Now you can use the arrow keys to scroll up and down through the output. Press q
to exit less
.
You can also filter the output using grep
to search for specific keywords, like "error" or the name of a hardware device.
For example, to see messages related to USB devices:
dmesg | grep -i usb
This command will show only the lines containing "usb" (case-insensitive due to the -i
flag).
Exploring the dmesg
output is a fundamental skill for Linux system administration and troubleshooting.
Click Continue to complete this lab.