0% found this document useful (0 votes)
50 views2 pages

Dmesg Tutorial

The dmesg command prints or controls the kernel ring buffer. It displays messages from the kernel ring buffer by default. The command has options to limit output to certain message levels like errors and warnings, add timestamps, and filter for specific devices or userspace messages only. The tutorial provides examples of using dmesg and explanations of its basic functionality.

Uploaded by

Slim Shady
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views2 pages

Dmesg Tutorial

The dmesg command prints or controls the kernel ring buffer. It displays messages from the kernel ring buffer by default. The command has options to limit output to certain message levels like errors and warnings, add timestamps, and filter for specific devices or userspace messages only. The tutorial provides examples of using dmesg and explanations of its basic functionality.

Uploaded by

Slim Shady
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Linux dmesg command

The dmesg command lets you print or control the kernel ring buffer. Following is
its syntax:

dmesg [options]

And here's how the tool's man page explains it:

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:

How to use dmesg command


Q2. How to limit the output only to error and warnings?

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):

emerg - system is unusable


alert - action must be taken immediately
crit - critical conditions
err - error conditions
warn - warning conditions
notice - normal but significant condition
info - informational
debug - debug-level messages

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

In my case, here's a part of output the above command produced:

How to limit the output only to error and warnings


Q3. How to make dmesg produce timestamps in output?

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

Following is an example output:

How to make dmesg produce timestamps in output


So you can see a timestamp is pre-fixed with each message.
Q4. How to make dmesg display info specific to a device?

Suppose you want dmesg to only display info related to eth0 interface. Here's how
you can do that:

dmesg | grep -i eth0

Following is an example output:

How to make dmesg display info specific to a device


Q5. How to make dmesg display only userspace messages?

If you want to limit dmesg's output only to userspace messages, use the -u command
line option.

dmesg -u

How to make dmesg display only userspace messages


Conclusion

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.

You might also like