DMESG

print or control the kernel ring buffer

dmesg geeft systeemboodschappen weer (vanaf de start van de computer tot het moment van uitschakelen) en is handig bij het opsporen van problemen. Afhankelijk van jouw Distro kun je dmesg gebruiken als “gewone” gebruiker, maar op mijn Debian systeem moet ik sudo gebruiken:

Figuur 1. $ sudo dmesg

$ sudo dmesg

Figuur 2. $ sudo dmesg
             ┌─[patrick@Linuxgebruikers.nl]─[~]
└──╼ $ sudo dmesg
[sudo] password for patrick: 
[    0.000000] microcode: microcode updated early to revision 0x29, date = 2013-06-12
[    0.000000] Linux version 4.15.0-2-amd64 (debian-kernel@lists.debian.org) (gcc version 7.3.0 (Debian 7.3.0-12)) #1 SMP Debian 4.15.11-1 (2018-03-20)
[    0.000000] Command line: BOOT_IMAGE=/vmlinuz-4.15.0-2-amd64 root=/dev/mapper/Battlestar--Pegasus--vg-root ro quiet
[    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: Supporting XSAVE feature 0x004: 'AVX registers'
[    0.000000] x86/fpu: xstate_offset[2]:  576, xstate_sizes[2]:  256
[    0.000000] x86/fpu: Enabled xstate features 0x7, context size is 832 bytes, using 'standard' format.
[    0.000000] e820: BIOS-provided physical RAM map:
[    0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009d7ff] usable
[    0.000000] BIOS-e820: [mem 0x000000000009d800-0x000000000009ffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000000e0000-0x00000000000fffff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000000100000-0x00000000df55bfff] usable
[    0.000000] BIOS-e820: [mem 0x00000000df55c000-0x00000000df5aafff] ACPI NVS
[    0.000000] BIOS-e820: [mem 0x00000000df5ab000-0x00000000df5cffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000df5d0000-0x00000000df5d0fff] usable
[    0.000000] BIOS-e820: [mem 0x00000000df5d1000-0x00000000df5e0fff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000df5e1000-0x00000000df5e9fff] ACPI NVS
[    0.000000] BIOS-e820: [mem 0x00000000df5ea000-0x00000000df5ecfff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000df5ed000-0x00000000df5f0fff] ACPI NVS
[    0.000000] BIOS-e820: [mem 0x00000000df5f1000-0x00000000df640fff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000df641000-0x00000000df683fff] ACPI NVS
[    0.000000] BIOS-e820: [mem 0x00000000df684000-0x00000000df7fffff] usable
[    0.000000] BIOS-e820: [mem 0x00000000fed1c000-0x00000000fed1ffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000ff000000-0x00000000ffffffff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000100000000-0x000000019f7fffff] usable
[    0.000000] NX (Execute Disable) protection: active
[    0.000000] random: fast init done
[    0.000000] SMBIOS 2.6 present.
[    0.000000] DMI: Dell Inc. XPS 8300  /0Y2MRG, BIOS A06 10/17/2011
[    0.000000] e820: update [mem 0x00000000-0x00000fff] usable ==> reserved
[    0.000000] e820: remove [mem 0x000a0000-0x000fffff] usable
[    0.000000] e820: last_pfn = 0x19f800 max_arch_pfn = 0x400000000
[    0.000000] MTRR default type: uncachable
[    0.000000] MTRR fixed ranges enabled:
[    0.000000]   00000-9FFFF write-back
[    0.000000]   A0000-BFFFF uncachable
        

Omdat dmesg veel meer gegevens weergeeft dan wat op het scherm kan getoond worden gebruik je best | less (pipe less) o.i.d. of als je enkel interesse hebt in een bepaald gedeelte, kun je met grep ook enkel dat laten weergeven wat je zoekt. $ sudo dmesg | less

Figuur 3. $ sudo dmesg | less
            [    0.000000]   E8000-FFFFF write-protect
[    0.000000] MTRR variable ranges enabled:
[    0.000000]   0 base 000000000 mask F00000000 write-back
[    0.000000]   1 base 100000000 mask F80000000 write-back
[    0.000000]   2 base 180000000 mask FE0000000 write-back
[    0.000000]   3 base 0E0000000 mask FE0000000 uncachable
[    0.000000]   4 base 19F800000 mask FFF800000 uncachable
[    0.000000]   5 disabled
[    0.000000]   6 disabled
[    0.000000]   7 disabled
[    0.000000]   8 disabled
[    0.000000]   9 disabled
[    0.000000] x86/PAT: Configuration [0-7]: WB  WC  UC- UC  WB  WP  UC- WT  
[    0.000000] e820: update [mem 0xe0000000-0xffffffff] usable ==> reserved
[    0.000000] e820: last_pfn = 0xdf800 max_arch_pfn = 0x400000000
[    0.000000] found SMP MP-table at [mem 0x000fcb80-0x000fcb8f] mapped at [        (ptrval)]
[    0.000000] Base memory trampoline at [        (ptrval)] 97000 size 24576
[    0.000000] BRK [0x19620000, 0x19620fff] PGTABLE
[    0.000000] BRK [0x19621000, 0x19621fff] PGTABLE
[    0.000000] BRK [0x19622000, 0x19622fff] PGTABLE
[    0.000000] BRK [0x19623000, 0x19623fff] PGTABLE
[    0.000000] BRK [0x19624000, 0x19624fff] PGTABLE
[    0.000000] BRK [0x19625000, 0x19625fff] PGTABLE
[    0.000000] BRK [0x19626000, 0x19626fff] PGTABLE
[    0.000000] BRK [0x19627000, 0x19627fff] PGTABLE
[    0.000000] RAMDISK: [mem 0x34fcf000-0x367defff]
[    0.000000] ACPI: Early table checksum verification disabled
[    0.000000] ACPI: RSDP 0x00000000000F0410 000024 (v02 DELL  )
[    0.000000] ACPI: XSDT 0x00000000DF5A4070 00005C (v01 DELL   FX09     20100118 AMI  00000097)
[    0.000000] ACPI: FACP 0x00000000DF5AA3F8 0000F4 (v04 DELL   FX09     20100118 AMI  00000097)
[    0.000000] ACPI: DSDT 0x00000000DF5A4158 00629E (v02 DELL   FX09     00000006 INTL 20051117)
[    0.000000] ACPI: FACS 0x00000000DF5EDE80 000040
[    0.000000] ACPI: APIC 0x00000000DF5AA4F0 000072 (v03 DELL   FX09     20100118 AMI  00000097)
[    0.000000] ACPI: SSDT 0x00000000DF5AA568 000102 (v01 AMICPU PROC     00000001 MSFT 03000001)
[    0.000000] ACPI: MCFG 0x00000000DF5AA670 00003C (v01 DELL   FX09     20100118 MSFT 00000097)
[    0.000000] ACPI: SLIC 0x00000000DF5AA6B0 000176 (v01 DELL   FX09     20100118 MSFT 00000097)
[    0.000000] ACPI: HPET 0x00000000DF5AA828 000038 (v01 DELL   FX09     20100118 AMI. 00000004)
[    0.000000] ACPI: OSFR 0x00000000DF5AA860 000080 (v01 DELL   FX09     07DB0A11 ASL  00000097)
[    0.000000] ACPI: Local APIC address 0xfee00000
[    0.000000] No NUMA configuration found
:
        

$ sudo dmesg | egrep -i bluetooth

Figuur 4. $ sudo dmesg | egrep -i bluetooth
                ┌─[patrick@Linuxgebruikers.nl]─[~]
└──╼ $ sudo dmesg | egrep -i bluetooth
[56122.723370] Bluetooth: Core ver 2.22
[56122.723383] Bluetooth: HCI device and connection manager initialized
[56122.723386] Bluetooth: HCI socket layer initialized
[56122.723387] Bluetooth: L2CAP socket layer initialized
[56122.723391] Bluetooth: SCO socket layer initialized
[56122.827427] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[56122.827428] Bluetooth: BNEP filters: protocol multicast
[56122.827432] Bluetooth: BNEP socket layer initialized
[56122.927020] Bluetooth: RFCOMM TTY layer initialized
[56122.927025] Bluetooth: RFCOMM socket layer initialized
[56122.927029] Bluetooth: RFCOMM ver 1.11
┌─[patrick@Linuxgebruikers.nl]─[~]
└──╼ $
            

Indien je het gebruik van grep/egrep niet kent, met de -i optie zet je grep in “CaSe Insensitive” modus, gebruik je dit niet dan zal dmesg niks weergeven want dan filtert grep/egrep op bluetooth en het staat in het log als bluetooth.

Als je het apparaat (bijv. een bluetooth USB dongle) net hebt aangesloten kun je er ook voor kiezen om enkel de laatste 10 of 20 regels van dmesg te laten weergeven.

$ sudo dmesg | tail -n 20

Figuur 5. $ sudo dmesg | tail -n 20
            ┌─[patrick@Linuxgebruikers.nl]─[~]
└──╼ $ sudo dmesg | tail -n 20
[55984.011737] userif-5: sent link up event.
[56011.163421] userif-5: sent link down event.
[56011.163424] userif-5: sent link up event.
[56103.323194] usb 1-1.2: USB disconnect, device number 4
[56122.233715] usb 1-1.2: new full-speed USB device number 7 using ehci-pci
[56122.682570] usb 1-1.2: New USB device found, idVendor=0a12, idProduct=0001
[56122.682574] usb 1-1.2: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[56122.723370] Bluetooth: Core ver 2.22
[56122.723382] NET: Registered protocol family 31
[56122.723383] Bluetooth: HCI device and connection manager initialized
[56122.723386] Bluetooth: HCI socket layer initialized
[56122.723387] Bluetooth: L2CAP socket layer initialized
[56122.723391] Bluetooth: SCO socket layer initialized
[56122.726948] usbcore: registered new interface driver btusb
[56122.827427] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[56122.827428] Bluetooth: BNEP filters: protocol multicast
[56122.827432] Bluetooth: BNEP socket layer initialized
[56122.927020] Bluetooth: RFCOMM TTY layer initialized
[56122.927025] Bluetooth: RFCOMM socket layer initialized
[56122.927029] Bluetooth: RFCOMM ver 1.11
┌─[patrick@Linuxgebruikers.nl]─[~]
└──╼ $
        

Andere opties van dmesg zijn oa.

– H : voor “Human” readable output, dit geeft de tijd van de melding weer in een door de mens leesbaar formaat: $ sudo dmesg -H

Figuur 6. $ sudo dmesg -H
                [Apr14 21:22] microcode: microcode updated early to revision 0x29, date = 2013-06-12
[  +0.000000] Linux version 4.15.0-2-amd64 (debian-kernel@lists.debian.org) (gcc version 7.3.0 (Debian 7.3.0-12)) #1 SMP Debian 4.15.
[  +0.000000] Command line: BOOT_IMAGE=/vmlinuz-4.15.0-2-amd64 root=/dev/mapper/Battlestar--Pegasus--vg-root ro quiet
[  +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: Supporting XSAVE feature 0x004: 'AVX registers'
[  +0.000000] x86/fpu: xstate_offset[2]:  576, xstate_sizes[2]:  256
[  +0.000000] x86/fpu: Enabled xstate features 0x7, context size is 832 bytes, using 'standard' format.
[  +0.000000] e820: BIOS-provided physical RAM map:
[  +0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009d7ff] usable
[  +0.000000] BIOS-e820: [mem 0x000000000009d800-0x000000000009ffff] reserved
[  +0.000000] BIOS-e820: [mem 0x00000000000e0000-0x00000000000fffff] reserved
[  +0.000000] BIOS-e820: [mem 0x0000000000100000-0x00000000df55bfff] usable
[  +0.000000] BIOS-e820: [mem 0x00000000df55c000-0x00000000df5aafff] ACPI NVS
[  +0.000000] BIOS-e820: [mem 0x00000000df5ab000-0x00000000df5cffff] reserved
[  +0.000000] BIOS-e820: [mem 0x00000000df5d0000-0x00000000df5d0fff] usable
[  +0.000000] BIOS-e820: [mem 0x00000000df5d1000-0x00000000df5e0fff] reserved
[  +0.000000] BIOS-e820: [mem 0x00000000df5e1000-0x00000000df5e9fff] ACPI NVS
[  +0.000000] BIOS-e820: [mem 0x00000000df5ea000-0x00000000df5ecfff] reserved
[  +0.000000] BIOS-e820: [mem 0x00000000df5ed000-0x00000000df5f0fff] ACPI NVS
[  +0.000000] BIOS-e820: [mem 0x00000000df5f1000-0x00000000df640fff] reserved
[  +0.000000] BIOS-e820: [mem 0x00000000df641000-0x00000000df683fff] ACPI NVS
[  +0.000000] BIOS-e820: [mem 0x00000000df684000-0x00000000df7fffff] usable
[  +0.000000] BIOS-e820: [mem 0x00000000fed1c000-0x00000000fed1ffff] reserved
[  +0.000000] BIOS-e820: [mem 0x00000000ff000000-0x00000000ffffffff] reserved
[  +0.000000] BIOS-e820: [mem 0x0000000100000000-0x000000019f7fffff] usable
[  +0.000000] NX (Execute Disable) protection: active
[  +0.000000] random: fast init done
[  +0.000000] SMBIOS 2.6 present.
[  +0.000000] DMI: Dell Inc. XPS 8300  /0Y2MRG, BIOS A06 10/17/2011
[  +0.000000] e820: update [mem 0x00000000-0x00000fff] usable ==> reserved
[  +0.000000] e820: remove [mem 0x000a0000-0x000fffff] usable
[  +0.000000] e820: last_pfn = 0x19f800 max_arch_pfn = 0x400000000
[  +0.000000] MTRR default type: uncachable
[  +0.000000] MTRR fixed ranges enabled:
[  +0.000000]   00000-9FFFF write-back
[  +0.000000]   A0000-BFFFF uncachable
[  +0.000000]   C0000-CFFFF write-protect
[  +0.000000]   D0000-E7FFF uncachable
[  +0.000000]   E8000-FFFFF write-protect
:
...
[Apr15 12:58] usb 1-1.2: new full-speed USB device number 7 using ehci-pci
[  +0.448855] usb 1-1.2: New USB device found, idVendor=0a12, idProduct=0001
[  +0.000004] usb 1-1.2: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[  +0.040796] Bluetooth: Core ver 2.22
[  +0.000012] NET: Registered protocol family 31
[  +0.000001] Bluetooth: HCI device and connection manager initialized
[  +0.000003] Bluetooth: HCI socket layer initialized
[  +0.000001] Bluetooth: L2CAP socket layer initialized
[  +0.000004] Bluetooth: SCO socket layer initialized
[  +0.003557] usbcore: registered new interface driver btusb
[  +0.100479] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[  +0.000001] Bluetooth: BNEP filters: protocol multicast
[  +0.000004] Bluetooth: BNEP socket layer initialized
[  +0.099588] Bluetooth: RFCOMM TTY layer initialized
[  +0.000005] Bluetooth: RFCOMM socket layer initialized
[  +0.000004] Bluetooth: RFCOMM ver 1.11
(END)
            

Zoals je kun zien krijg je nu de datum en tijd van de meldingen, ook heb je bijv. |less niet nodig in dit geval.

-d : Dit geeft de “Delta” tijd weer, dat is de tijd tussen de verschillende meldingen.

-f : Facility list laat toe om enkel meldingen die tot een bepaalde “facility” behoren weer te geven (bijv. enkel de meldingen met betrekking tot de daemons)

$ sudo dmesg -f daemon

Figuur 7. $ sudo dmesg -f daemon
                ┌─[patrick@Linuxgebruikers.nl]─[~]
└──╼ $ sudo dmesg -f daemon
[    1.872384] systemd[1]: systemd 238 running in system mode. (+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN -PCRE2 default-hierarchy=hybrid)
[    1.892297] systemd[1]: Detected architecture x86-64.
[    1.895433] systemd[1]: Set hostname to <Shark-Two>.
[    1.969589] systemd[1]: Started Forward Password Requests to Wall Directory Watch.
[    1.969666] systemd[1]: Listening on fsck to fsckd communication Socket.
[    1.969721] systemd[1]: Listening on LVM2 poll daemon socket.
[    1.969737] systemd[1]: Reached target System Time Synchronized.
[    1.969795] systemd[1]: Listening on Journal Socket (/dev/log).
[    1.970414] systemd[1]: Created slice User and Session Slice.
[    1.970470] systemd[1]: Listening on Device-mapper event daemon FIFOs.
┌─[patrick@Linuxgebruikers.nl]─[~]
└──╼ $
            

-D : Console Off (stop het weergeven van deze meldingen in de Console/Terminal)

-E : Console On (Start het weergeven van deze meldingen in de Console/Terminal)

dmesg heeft nog vele andere mogelijkheden, voor een volledige lijst kun je zoals altijd de manpages en/of infopages raadplegen.