dmesg - Unix, Linux Command


Advertisements

Previous Page
Next Page  
 

NAME

dmesg print or control the kernel ring buffer

SYNOPSIS

dmesg [options]
dmesg --clear
dmesg --read-clear [options]
dmesg --console-level level
dmesg --console-on
dmesg --console-off

DESCRIPTION

dmesg is used to examine or control the kernel ring buffer.

The default action is to display all messages from the kernel ribuffer.

OPTIONS

TAG DESCRIPTION
-C, --clear Clear the ring buffer. .
-c, --read-clear Clear the ring buffer after first printing its contents

 

-D, --console-off Disable the printing of messages to the console..
-d, --show-delta Display the timestamp and the time delta spent between messages. If used together with --notime then only the time delta without the timestamp is printed.
E, --console-on Enable printing messages to the console..
-f, --facility list Restrict output to the given (comma-separated) list of facilities. For example: dmesg --facility=daemon
-k, --kernel Print kernel messages.
-l, --level list Restrict output to defined (comma-separated) list of levels.
-n, --console-level level Set the level at which logging of messages is done to the console. The level is a level number or abbreviation of the level name. For all supported levels see the dmesg --help output.
-r, --raw Print the raw message buffer, i.e. do not strip the log-level prefixes.
-s, --buffer-size size Use a buffer of size to query the kernel ring buffer. This is 16392 by default. (The default kernel syslog buffer size was 4096 at first, 8192 since 1.3.54, 16384 since 2.1.113.) If you have set the kernel buffer to be larger than the default, then this option can be used to view the entire buffer
-T, --ctime rint human-readable timestamps
-t, --notime Do not print kernel's timestamps.
-u, --userspace Print userspace messages
-x, --decode Decode facility and level (priority) numbers to human-readable prefixes..
-V, --version Display version information and exit.
-h, --help Display help text and exit.

EXAMPLES

EXAMPLE-1:

Output all kernel messages currently in the ring buffer to a file called kernel_msgs.txt:

$ dmesg > kernel_msgs.txt

output:
cat dmesg.txt
[ 0.000000] Initializing cgroup subsys cpuset
[ 0.000000] Initializing cgroup subsys cpu
[ 0.000000] Initializing cgroup subsys cpuacct
[ 0.000000] Linux version 3.19.0-78-generic (buildd@lgw01-17) (gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3) ) #86~14.04.1-Ubuntu SMP Tue Dec 6 17:58:35 UTC 2016 (Ubuntu 3.19.0-78.86~14.04.1-generic 3.19.8-ckt22)
.....
.....

EXAMPLE-2:

Display only those kernel messages which relate to memory usage:

$ dmesg | grep -i memory


output:
[ 0.000000] Scanning 1 areas for low memory corruption
[ 0.000000] Base memory trampoline at [ffff880000099000] 99000 size 24576
[ 0.000000] init_memory_mapping: [mem 0x00000000-0x000fffff]
[ 0.000000] init_memory_mapping: [mem 0x7fc00000-0x7fdfffff]
[ 0.000000] init_memory_mapping: [mem 0x60000000-0x7fbfffff]
...
....

EXAMPLE-3:

To discover the hard disk detected by kernel:

$ dmesg | grep sda

output:
[ 5.701937] sd 2:0:0:0: [sda] 39928544 512-byte logical blocks: (20.4 GB/19.0 GiB)
[ 5.702027] sd 2:0:0:0: [sda] Write Protect is off
[ 5.702124] sd 2:0:0:0: [sda] Mode Sense: 00 3a 00 00
[ 5.702436] sd 2:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[ 5.733250] sda: sda1 sda2 < sda5 >
[ 5.734518] sd 2:0:0:0: [sda] Attached SCSI disk

EXAMPLE-4:

To view Ethernet lin status:

$ dmesg | grep eth

output:
[ 5.379042] e1000 0000:00:03.0 eth0: (PCI:33MHz:32-bit) 08:00:27:68:eb:f1
[ 5.379047] e1000 0000:00:03.0 eth0: Intel(R) PRO/1000 Network Connection
[ 19.813578] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[ 19.816591] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX
[ 19.824621] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[49699.050936] e1000: eth0 NIC Link is Down
[49699.051214] e1000 0000:00:03.0 eth0: Reset adapter
[49701.111247] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX

EXAMPLE-5:

To Clear messages in dmesg buffer:

$ dmesg -c

 

Previous Page
Next Page