I am running a Debian system, and find the output of the dmesg command very helpful.
Can somebody explain to me what information is output by the dmesg command? Is it a 1:1 correlation to the kern.* messages in syslog?
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.Sign up to join this community
Technically speaking dmesg prints the kernel ring buffer to standard output.
I don't know why they call it the ring buffer, but it's basically a log buffer. All of the kernel boot messages get written there. If you are running syslog then all, or most, of these messages will also probably be written to there as well. However, the dmesg command is seperate from syslog. It is part of linux utils, and you can use it even if you do not have syslog.
dmesg can also be used to clear the ring buffer itself, and also to change the level at which errors show up in console. Sometimes, depending on the seriousness of a message, it will be sent to every console in addition to the ring buffer. A good example of this is a shutdown message.
dmesg -n levelnumber allows you to change the level of seriousness a message must have to be sent to the consoles in addition to the buffer.
As has been said dmesg allows you to dump the kernel ring buffer or control it. Usually you'll get boot messages, but a server that has been up for a while and has had chatty kernel messages will most likely have had the boot messages overwritten. Most distros will run dmesg in a start up script to dump the boot messages to a log file - usually /var/log/dmesg.
The kernel ring buffer tends to come into it's own when you get a kernel panic and a crash dump to look at. One of the first things you're likely to look at is the contents of the ring buffer, which will hopefully give you a pointer as tho what went wrong. When you hit a panic, the kernel will most likely not get a chance to pass these message to syslog, so the crash dump will be the only place you'll be able to see them.