Sep 29, 2019
clear the kernel ring buffer
Exclusive options : -D, -E, -c, -n
read and clear all messages
Exclusive options : -C, -D, -E, -n
disable printing messages to console
Exclusive options : -C, -E, -c, -n
enable printing messages to console
Exclusive options : -C, -D, -c, -n
use the file instead of the kernel log buffer
Exclusive options : (none)
restrict output to defined facilities
Exclusive options : (none)
Supported log facilities:
0 : kern - kernel messages (same as "dmesg -k")
1 : user - random user-level messages
2 : mail - mail system
3 : daemon - system daemons
4 : auth - security/authorization messages
5 : syslog - messages generated internally by syslogd
6 : lpr - line printer subsystem
7 : news - network news subsystem
human readable output
Exclusive options : -r
It displays the messages on pager, with colored letter and time delta from previous row.
$ dmesg -H
[Sep28 10:32] Initializing cgroup subsys cpuset
[ +0.000000] Initializing cgroup subsys cpu
[ +0.000000] Initializing cgroup subsys cpuacct
[ +0.000000] Linux version 3.10.0-957.el7.x86_64
...
[ +0.000075] alg: No test for __generic-gcm-aes-aesni
[Sep28 10:33] ppdev: user-space parallel port driver
[ +0.568156] Adding 839676k swap on /dev/mapper/centos-swap.
...
display kernel messages
Exclusive options : (none)
It displays the messages other than "dmesg -u".
colorize messages
Exclusive options : -r
restrict output to defined levels
Exclusive options : (none)
Supported log levels (priorities):
0 : emerg - system is unusable
1 : alert - action must be taken immediately
2 : crit - critical conditions
3 : err - error conditions
4 : warn - warning conditions
5 : notice - normal but significant condition
6 : info - informational
7 : debug - debug-level messages
set level of messages printed to console
Exclusive options : -C, -D, -E, -c
For example, if you set "dmesg -n 6", the logs from '0 : emerg' to '5 : notice' are enabled.
do not pipe output into a pager
Exclusive options : (none)
print the raw message buffer
Exclusive options : -H, -L
This option shows the messages with log level.
$ dmesg -r
...
<6>[ 0.000000] SMBIOS 2.5 present.
<6>[ 0.000000] DMI: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
<6>[ 0.000000] Hypervisor detected: KVM
<7>[ 0.000000] e820: update [mem 0x00000000-0x00000fff] usable ==> reserved
<7>[ 0.000000] e820: remove [mem 0x000a0000-0x000fffff] usable
<6>[ 0.000000] e820: last_pfn = 0x6fff0 max_arch_pfn = 0x400000000
<7>[ 0.000000] MTRR default type: uncachable
<7>[ 0.000000] MTRR variable ranges disabled:
<6>[ 0.000000] PAT configuration [0-7]: WB WC UC- UC WB WP UC- UC
...
force to use syslog(2) rather than /dev/kmsg
Exclusive options : -w
buffer size to query the kernel ring buffer
Exclusive options : (none)
display userspace messages
Exclusive options : (none)
It displays the messages other than "dmesg -k".
wait for new messages
Exclusive options : -S
This option should be same as "cat /dev/kmsg".
decode facility and level to readable string
Exclusive options : -r
Example:
$ dmesg -x
...
kern :info : [ 9.679729] piix4_smbus 0000:00:07.0: SMBus Host Controller at 0x4100, revision 0
kern :info : [ 9.771938] input: PC Speaker as /devices/platform/pcspkr/input/input5
kern :notice: [ 9.833041] sr 1:0:0:0: Attached scsi generic sg0 type 5
kern :notice: [ 9.833142] sd 2:0:0:0: Attached scsi generic sg1 type 0
kern :info : [ 10.178801] cryptd: max_cpu_qlen set to 1000
kern :notice: [ 10.324364] XFS (sda1): Mounting V5 Filesystem
...
show time delta between printed messages
Exclusive options : -r
Example:
$ dmesg -d
...
[ 9.679729 < 0.201613>] piix4_smbus 0000:00:07.0: SMBus Host Controller at 0x4100, revision 0
[ 9.771938 < 0.092209>] input: PC Speaker as /devices/platform/pcspkr/input/input5
[ 9.833041 < 0.061103>] sr 1:0:0:0: Attached scsi generic sg0 type 5
[ 9.833142 < 0.000101>] sd 2:0:0:0: Attached scsi generic sg1 type 0
[ 10.178801 < 0.345659>] cryptd: max_cpu_qlen set to 1000
[ 10.324364 < 0.145563>] XFS (sda1): Mounting V5 Filesystem
...
(I wonder it should be the output of '-e' in fact.)
show local time and time delta in readable format
Exclusive options : -r
Example:
$ dmesg -e
...
[ +0.201613] piix4_smbus 0000:00:07.0: SMBus Host Controller at 0x4100, revision 0
[ +0.092209] input: PC Speaker as /devices/platform/pcspkr/input/input5
[ +0.061103] sr 1:0:0:0: Attached scsi generic sg0 type 5
[ +0.000101] sd 2:0:0:0: Attached scsi generic sg1 type 0
[ +0.345659] cryptd: max_cpu_qlen set to 1000
[ +0.145563] XFS (sda1): Mounting V5 Filesystem
...
(I wonder it should be the output of '-d' in fact.)
show human-readable timestamp (may be inaccurate!)
Exclusive options : -r
Example:
$ dmesg -T
...
[Sun Sep 29 09:44:39 2019] piix4_smbus 0000:00:07.0: SMBus Host Controller at 0x4100, revision 0
[Sun Sep 29 09:44:39 2019] input: PC Speaker as /devices/platform/pcspkr/input/input5
[Sun Sep 29 09:44:39 2019] sr 1:0:0:0: Attached scsi generic sg0 type 5
[Sun Sep 29 09:44:39 2019] sd 2:0:0:0: Attached scsi generic sg1 type 0
[Sun Sep 29 09:44:40 2019] cryptd: max_cpu_qlen set to 1000
[Sun Sep 29 09:44:40 2019] XFS (sda1): Mounting V5 Filesystem
...
don't show any timestamp with messages
Exclusive options : -r
Confirmed version of Linux : CentOS 7.6.1810 (dmesg from util-linux 2.23.2)
The source code file dmesg.c is on git-hub. See it if you like.