The dmesg command is a great command for troubleshooting hardware issues. When a system initially boots, the kernel will identify the various hardware devices available to that system. As the kernel identifies these devices, the information is written to the kernel’s ring buffer. This ring buffer is essentially an internal log for the kernel. The dmesg command can be used to print this ring buffer.

The following is an example output from the dmesg command:

# dmesg
[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Initializing cgroup subsys cpuacct
[    0.000000] Linux version 3.10.0-229.1.2.el7.x86_64 ([email protected]) (gcc version 4.8.2 20140120 (Red Hat 4.8.2-16) (GCC) ) #1 SMP Fri Mar 27 03:04:26 UTC 2015
[    0.000000] Command line: BOOT_IMAGE=/vmlinuz-3.10.0-229.1.2.el7.x86_64 root=/dev/mapper/md0-root ro rd.lvm.lv=md0/swap crashkernel=auto rd.md.uuid=bec13d99:42674929:76663813:f748e7cb rd.lvm.lv=md0/root rd.md.uuid=7adf0323:b0962394:387e6cd0:b2914469 rhgb quiet LANG=en_US.UTF-8 systemd.debug
[    0.000000] e820: BIOS-provided physical RAM map:
[    0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable
[    0.000000] BIOS-e820: [mem 0x000000000009fc00-0x000000000009

You can use the option -T to view the messages along with the timestamp.

dmesg Command Examples

1. To print or control the kernel ring buffer:

2. To clear the kernel ring buffer after printing:

3. To print the raw message buffer:

4. To specify the ring buffer size:

5. To set the level of logging:

# dmesg -n level
# dmesg -n 1      ## prevent all messages