Hacker News new | past | comments | ask | show | jobs | submit login
Dmesg: An old, new, cool tool (inconsolation.wordpress.com)
70 points by aw3c2 on Aug 11, 2013 | hide | past | favorite | 9 comments



You need to have a recent util-linux for most of these. If you're on Ubuntu, you probably have 2.20.

From the release notes:

2.20: supports new command line options: --clear, --console-on, --console-off, --ctime, --decode, --facility=<list>, --level=<list>, --show-delta, --notime, --kernel and --userspace

2.21: supports new command line options --file to read the log from a file rather than from kernel buffer

2.22:

- reads kernel messages from /dev/kmsg on kernel 3.5

- supports new option --follow to wait for new messages (kernel 3.5 required)

- supports new option --reltime to print human readable deltas

2.23: supports new command line options --color, --human and --nopager, the --human option enables relative times, colors and pager support.


I wonder (other than the features requiring kernel 3.5) what dependencies dmesg has - could I just carry a static binary around in my ~/bin for systems that don't have a new util-linux?


Check for yourself with `ldd <path/to/dmesg>`


Ubuntu 12.04 (32-bit)

   [~]$ ldd /bin/dmesg
   	linux-gate.so.1 =>  (0xb778e000)
   	libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb75c4000)
   	/lib/ld-linux.so.2 (0xb778f000)
CentOS 6.4 (64-bit)

   [~]$ ldd /bin/dmesg
   	linux-vdso.so.1 =>  (0x00007fff115ff000)
   	libc.so.6 => /lib64/libc.so.6 (0x00007ff8077c0000)
   	/lib64/ld-linux-x86-64.so.2 (0x00007ff807b59000)


On CentOS 6.4 the util-linux-ng v2.17.2 package provide the /bin/dmesg command.


On systems that have been up a long time or that spew lots of kernel messages, running dmesg might not give you everything (i.e. just a buffer of the last X messages), you can typically find a complete dmesg log in /var/log/dmesg, which should have a complete dmesg log from boot. I use dmesg a lot, for debugging issue, check if drivers have been loaded, kernel messages, like ops or oom, etc. Very handy!


I was kinda hoping to get a description of what dmesg actually is/does...but it's mostly about customizing the output. I could search for it of course, but it was a bit of a surprise to not see any intro to it.

I've been using dmesg for awhile on Arch to debug USB devices mostly, without any clue to what it actually is.


dmesg reads and displays the contents of /proc/kmsg. /proc/kmsg is an interface to a buffer where the output from calls to printk is stored. printk is the linux kernel's equivalent of libc's printf function.


First time I learn that dmesg takes arguments!




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: