Dmesg Tutorial
Dmesg Tutorial
The dmesg command lets you print or control the kernel ring buffer. Following is
its syntax:
dmesg [options]
dmesg is used to examine or control the kernel ring buffer. The default action is
to display all
messages from the kernel ring buffer.
Following are some Q&A-styled examples that should give you a better idea on how
the dmesg command works.
Q1. How to use dmesg command?
You can start using the dmesg command sans any command line option.
dmesg
For example, here's a small part of output the command produced in my case:
If you run dmesg on your system, you'll observe it outputs plethora of information.
Depending upon what you're looking for, you may want to filter or limit the output.
For its part, dmesg offers you this ability through 'levels.' Following is the
complete list of levels (along with their explanation):
So for example, if you want to limit the output to only error and warnings, you can
do that in the following way:
dmesg --level=err,warn
Sometimes, you may want a timestamp to be associated with the messages dmesg
produces. This can be done using the -T command line option, which produces human
readable timestamps.
dmesg -T
Suppose you want dmesg to only display info related to eth0 interface. Here's how
you can do that:
If you want to limit dmesg's output only to userspace messages, use the -u command
line option.
dmesg -u
Agreed, dmesg is not the kind of command you'll need everyday. But this is the tool
to turn to when someone (whom you've asked for help on certain topic) asks you to
provide kernel messages. I've mostly seen this case in online user forums, where
experienced users ask for kernel output.
Here, in this tutorial, we have discussed the dmesg command from beginners point of
view (just to get you started). Once you are done practicing all that we've
discussed here, head to the tool's man page.