If you have been using Linux for some time, you will likely have come to appreciate how stable and configurable it is, especially if you have some idea of managing a Linux system well. One such tool in managing a system is checking the
dmesg kernel log regularly, and especially when there is a problem with the system. The first place to go to is often the
In this tutorial, you will learn:
- How to access the
- How to use standard date and timestamps instead of the default (the number seconds since kernel was started)
- What sort of information you can see in the kernel log
Software requirements and conventions used
|Category||Requirements, Conventions or Software Version Used|
|Software||Bash command line, Linux based system|
|Other||Any utility which is not included in the Bash shell by default can be installed using
|Conventions||# – requires linux-commands to be executed with root privileges either directly as a root user or by use of
$ – requires linux-commands to be executed as a regular non-privileged user
How to access the dmesg kernel log
To access the
dmesg kernel log, simply execute the
dmesg command from your console prompt, no administrative (root) privileges are required (by default) to access the log:
$ dmesg ... [64283.356724] INFO: task cp:647102 blocked for more than 120 seconds. ... [97931.332991] ACPI: Preparing to enter system sleep state S3 [97931.704526] PM: Saving platform NVS memory [97931.704591] Disabling non-boot CPUs ... [97931.707220] smpboot: CPU 1 is now offline ... [97931.746603] ACPI: Low-level resume complete [97931.746667] PM: Restoring platform NVS memory [97931.748520] Enabling non-boot CPUs ... [97931.748551] x86: Booting SMP configuration: [97931.748551] smpboot: Booting Node 0 Processor 1 ...
Whenever you insert a new disk into the system, put the system to sleep, or do many other things, the kernel log will keep track of these events and record them for later review. Simply executing
dmesg at the command prompt brings up all information, in chronological order, with a leading time index since the system (or more specifically; the kernel) started, in the format of
The dmesg kernel log with regular date and timestamps
You can also request for the log to be printed in a more human-friendly ISO date and timestamp format:
$ dmesg --time-format=iso ... 2021-03-14T13:49:21,917805+11:00 sd 3:0:0:0: [sda] Starting disk ...
Scrolling through the dmesg log
If you want to scroll through the full dmesg output since the start, use a pipe (
Information provided by driversVarious drivers may also write to the log, and such messages are usually prefixed with a leading tag indicating the driver which is writing information:$ dmesg ... [ 2.006753] usb 1-6: Product: USB Optical Mouse ... [ 12.197240] snd_hda_intel 0000:01:00.1: bound 0000:01:00.0 ...
In this article, we briefly looked at the
dmesgkernel log, how to access it, and what sort of information you can obtain from this log. The
dmesglog is a primary troubleshooting tool whenever something is amiss with your Linux system. Enjoy dmesg!