Skip to main content
Engineering LibreTexts

06-C.9: The dmesg Command

  • Page ID
    32837
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)

    The dmesg Command

    dmesg (there are several sources that disagree on the name: "diagnostic message," “driver message” or “display message” are all options) is a command that prints the message buffer of the kernel. The output of this command typically contains the messages produced by the device drivers.

    On most Linux systems, the boot process generates a particularly dense stream of kernel messages. Many administrative issues pertain to whether a desired hardware device is successfully enumerated during the boot process, so the diagnostic process for a failed device often begins by inspecting the dmesg output from the kernel identification message to the point where the boot process concludes. Since this buffer can be overwritten by a flood of messages in subsequent operation, many Unix-like distributions store a post-boot copy of the message buffer at /var/log/dmesg or similar secure system location.

    It is also common to manually consult the current dmesg buffer after hot-plugging devices, particularly USB devices (especially thumb drives), to determine whether the device has been recognized, the data rate of the port involved (USB 2 and USB 3.0 plugs sit side by side and are hard to distinguish on many systems), what driver has been assigned, and where the device is made visible in the file system. Many distributions attempt to display device-recognition messages on the desktop, often through a taskbar pop-up, but this is not always reliable or the information presented is incomplete. (Furthermore, to be notified on the desktop, the hot-plugged device must be permitted by the system's security policy.)

    Syntax:

    dmesg [ OPTIONS ]
    

    Options:

    Option Choice Meaning
    -c, --read-clear Clear the ring buffer after first printing its contents.
    -e, --reltime Display the local time and the delta in human-readable format. Be aware that conversion to the local time could be inaccurate (see -T for more details).
    -f, --facility list Restrict output to the given (comma-separated) list of facilities.
    -H, --human Enable human-readable output. See also --color, --reltime and --nopager.
    -L, --color[=when] Colorize the output. The optional argument when can be auto, never or always. If the when argument is omitted, it defaults to auto. The colors can be disabled; for the current built-in default see the --help output. See also the COLORS section below.
    -l, --level list Restrict output to the given (comma-separated) list of levels.

    There is a LOT of information that is output from dmesg, and most of it takes a a bit of deciphering, but if you are looking for a specific device that is failing or having issues:

    pbmac@pbmac-server $ dmesg -H
    [Aug 4 12:58] Linux version 4.15.0-91-generic (buildd@lgw01-amd64-013) (gcc version 
    [  +0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-4.15.0-91-generic root=UUID=6e7
    [  +0.000000] KERNEL supported cpus:
    [  +0.000000]   Intel GenuineIntel
    [  +0.000000]   AMD AuthenticAMD
    [  +0.000000]   Centaur CentaurHauls
    [  +0.000000] x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point registers
    [  +0.000000] x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers'
    [  +0.000000] x86/fpu: Enabled xstate features 0x3, context size is 576 bytes, using
    [  +0.000000] e820: BIOS-provided physical RAM map:
    [  +0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009a7ff] usable
    [  +0.000000] BIOS-e820: [mem 0x00000000000f0000-0x00000000000fffff] reserved
    [  +0.000000] BIOS-e820: [mem 0x0000000000100000-0x00000000bfdffbff] usable
    [  +0.000000] BIOS-e820: [mem 0x00000000bfdffc00-0x00000000bfe53bff] ACPI NVS
    [  +0.000000] BIOS-e820: [mem 0x00000000bfe53c00-0x00000000bfe55bff] ACPI data
    [  +0.000000] BIOS-e820: [mem 0x00000000bfe55c00-0x00000000bfffffff] reserved
    [  +0.000000] BIOS-e820: [mem 0x00000000f8000000-0x00000000fbffffff] reserved
    [  +0.000000] BIOS-e820: [mem 0x00000000fec00000-0x00000000fed003ff] reserved
    [  +0.000000] BIOS-e820: [mem 0x00000000fed20000-0x00000000fed9ffff] reserved
    [  +0.000000] BIOS-e820: [mem 0x00000000fee00000-0x00000000feefffff] reserved
    [  +0.000000] BIOS-e820: [mem 0x00000000ffb00000-0x00000000ffffffff] reserved
    [  +0.000000] BIOS-e820: [mem 0x0000000100000000-0x000000033bffffff] usable
    [  +0.000000] NX (Execute Disable) protection: active
    :
    

    Many dmesg lines in a traditional system begin with a device name followed by a colon, followed by some detailed text. Often these come in clusters, with the same device showing up on multiple lines in succession. Each cluster is usually associated with a single device enumeration, by one particular device driver (or device facility) associated with the device name.

    Adapted from:
    "dmesg" by Multiple ContributorsWikipedia is licensed under CC BY-SA 3.0


    06-C.9: The dmesg Command is shared under a CC BY-NC license and was authored, remixed, and/or curated by LibreTexts.

    • Was this article helpful?