Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

4 Answers 4

up vote 3 down vote accepted

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.

share|improve this answer
8  
They call it a ring buffer because it "wraps around" at a certain size. It will drop messages from the start of the buffer to hold news ones at the end. That is, iirc... –  wzzrd Jun 12 '09 at 14:29
    
wzzrd is correct. The buffer wraps when full and you lose some of the earlier messages. –  Joe Jun 12 '09 at 14:30
    
Its called a ring buffer because it is allocated in a cyclic manner. The buffer has space for a fixed number of logs, and once the last element is used the first space will be overwritten. en.wikipedia.org/wiki/Ring_buffer –  Russell Heilling Jun 12 '09 at 14:31
    
Is the same facility used to write messages to the kernel ring buffer as is used to send messages to kern.* in syslog? I am not so concerned about the boot messages, but rather the messages of the running system. –  Brent Jun 12 '09 at 15:02
1  
A ring buffer is like Homer's brain: Homer: every time I learn something new, it pushes some old stuff out of my brain. Remember when I took that home wine making course and I forgot how to drive? Marge: That's because you were drunk! Homer: And how... –  Banjer Aug 10 '10 at 18:33

Quoting the manpage:

   dmesg is used to examine or control the kernel ring buffer.

Many of those messages go to syslog as well, but not all. Also, syslog is not available until late(r) in the boot process.

share|improve this answer

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.

share|improve this answer

Dmesg print or control the kernel ring buffer. The program helps users to print out their bootup messages.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.