4

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?

Brent
  • 22,219
  • 19
  • 68
  • 102

4 Answers4

5

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.

Apreche
  • 1,405
  • 4
  • 17
  • 20
  • 10
    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. http://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
  • 2
    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
  • In CentOS, dmesg lines have "[ 0.0000] Some log." What's the number in the [...]? – Chris F Jun 08 '17 at 19:10
2

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.

Joe
  • 1,535
  • 1
  • 10
  • 15
2

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.

Brent
  • 22,219
  • 19
  • 68
  • 102
goo
  • 2,838
  • 18
  • 15
0

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

Caterpillar
  • 1,122
  • 2
  • 22
  • 47