Home > Linux > dmesg gets Human Readable Output

dmesg gets Human Readable Output

February 18th, 2014 Leave a comment Go to comments

Many Linux command line tools, such as ls or du, have a “human” option to make it more readable by… humans. When you want to get the kernel log, to find otu potential problems, you’d usually run dmesg, which dump the complete log in one go and looks like:

[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Initializing cgroup subsys cpuacct
[    0.000000] Linux version 3.11.0-15-generic (buildd@roseapple) (gcc version 4.8.1 (Ubuntu/Linaro 4.8.1-10ubuntu8) ) #25-Ubuntu SMP Thu Jan 30 17:22:01 UTC 2014 (Ubuntu 3.11.0-15.25-generic 3.11.10)
[    0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-3.11.0-15-generic root=UUID=9c042788-fa75-4fc4-9b12-598c809410e8 ro quiet splash
[    0.000000] KERNEL supported cpus:
[    0.000000]   Intel GenuineIntel
[    0.000000]   AMD AuthenticAMD
[    0.000000]   Centaur CentaurHauls
[    0.000000] e820: BIOS-provided physical RAM map:
[    0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009f7ff] usable
[    0.000000] BIOS-e820: [mem 0x000000000009f800-0x000000000009ffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000000f0000-0x00000000000fffff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000000100000-0x00000000bfd9ffff] usable
[    0.000000] BIOS-e820: [mem 0x00000000bfda0000-0x00000000bfdd0fff] ACPI NVS
[    0.000000] BIOS-e820: [mem 0x00000000bfdd1000-0x00000000bfdfffff] ACPI data
[    0.000000] BIOS-e820: [mem 0x00000000bfe00000-0x00000000bfefffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000e0000000-0x00000000efffffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000fec00000-0x00000000ffffffff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000100000000-0x000000043effffff] usable

The more recent version of util-linux add support for “human” output option which looks better, and adds some colors for better readability, and shows one page at a time. Run it as dmesg --human
dmesg_human
You’ll also notice it won’t wrap long time, e.g. “Command line: …”

Instead of listing the total time on the right, it will display the time taken by an individual tasks. For example:

[    0.065115] ftrace: allocating 27844 entries in 109 pages
[    1.555780] ..TIMER: vector=0x30 apic1=0 pin1=2 apic2=-1 pin2=-1

will show as

[  +0.055397] ftrace: allocating 27844 entries in 109 pages
[  +1.490665] ..TIMER: vector=0x30 apic1=0 pin1=2 apic2=-1 pin2=-1

when using human readable option.

If your linux-util version is not recent enough, human readable option won’t be available. You can build the code as follows:

git clone git://git.kernel.org/pub/scm/utils/util-linux/util-linux.git util-linux
cd util-linux/
sudo apt-get install autopoint libtool
./autogen.sh 
./configure 
make

If you have an earlier version, you could also get something similar with commands like:

dmesg -L -e

For color, and per task timestamps.

or

dmesg | less

To display the output page per page.

Via Greg KH.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter

Categories: Linux Tags: Linux, dmesg, kernel, terminal
  1. Sander
    February 18th, 2014 at 15:23 | #1

    don’t forget the “sudo make install”…

  2. Diego.
    February 18th, 2014 at 15:41 | #2

    Another useful option of recent dmesg versions is “-w” which allows you to follow output of the kernel like with “tail -f”.

  3. Grr
    February 18th, 2014 at 17:42 | #3

    That’s useful. Thanks :)

  4. February 18th, 2014 at 23:26 | #4

    Very nice. But I got an error, when I execute mount :

    mount: /lib/arm-linux-gnueabihf/libmount.so.1: version `MOUNT_2.25′ not found (required by mount)
    mount: /lib/arm-linux-gnueabihf/libmount.so.1: version `MOUNT_2.23′ not found (required by mount)
    mount: /lib/arm-linux-gnueabihf/libmount.so.1: version `MOUNT_2.21′ not found (required by mount)
    mount: /lib/arm-linux-gnueabihf/libmount.so.1: version `MOUNT_2.24′ not found (required by mount)
    mount: /lib/arm-linux-gnueabihf/libmount.so.1: version `MOUNT_2.22′ not found (required by mount)

    To fix, I removed the symbolic link:
    rm -r -I /lib/arm-linux-gnueabihf/libmount.so.1

    At least, I think it is fixed …

    By the way, any other hint to get a more human (or beautiful) linux ?

  5. Alfred Braithewaite
    February 24th, 2014 at 09:51 | #5

    “checking for SYSTEMD_DAEMON”

    Even these simple fundamental system utilities have become infected with the requirements of systemd.

    systemd — all your programs and log files belong to us.

  1. No trackbacks yet.