Geek Culture
Published in

Geek Culture

Linux command: dmesg | uname

An overview of the Linux “dmesg” and “uname” command

Photo by Lucas Kapla on Unsplash

Kernel Ring Buffer

The kernel ring buffer is a data structure that records messages related to the kernel's operation. It is a special kind of buffer with a constant size, so as an outcome while receiving new messages automatically deletes the older ones.

dmesg (diagnostic message)

dmesgcommand displays kernel-related messages on Unix-like systems. It is used to control the kernel ring buffer. The contents of that ring buffer can be seen at any time using the dmesg command, and its contents are also saved to /var/log/dmesg file.

>> dmesg | less

[ 0.000000] Linux version 5.4.0-131-generic (buildd@lcy02-amd64-108) (gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1)) #147-Ubuntu SMP Fri Oct 14 17:07:22 UTC 2022 (Ubuntu 5.4.0-131.147-generic 5.4.210)
[ 0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-5.4.0-131-generic root=LABEL=cloudimg-rootfs ro console=tty1 console=ttyS0
[ 0.000000] KERNEL supported cpus:
[ 0.000000] Intel GenuineIntel
[ 0.000000] AMD AuthenticAMD
[ 0.000000] Hygon HygonGenuine
[ 0.000000] Centaur CentaurHauls
[ 0.000000] zhaoxin Shanghai
[ 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'
....
....

Some important options:

>> dmesg -h

Options:
-f, --facility <list> restrict output to defined facilities
-k, --kernel display kernel messages
-l, --level <list> restrict output to defined levels
-S, --syslog force to use syslog(2) rather than /dev/kmsg
-u, --userspace display userspace messages
-w, --follow wait for new messages
-T, --ctime show human-readable timestamp (may be inaccurate!)

Supports logs from the following facilities:

kern — kernel messages
user — random user-level messages
mail — mail system
daemon — system daemons
auth — security/authorization messages
syslog — messages generated internally by syslogd
lpr — line printer subsystem
news — network news subsystem

Filter logs by facilities:

>> dmesg -f syslog | less     

[ 10.250252] systemd-journald[355]: Received client request to
flush runtime journal.

Supports the following log levels (priorities):

emerg — system is unusable
alert — action must be taken immediately
crit — critical conditions
err — error conditions
warn — warning conditions
notice — normal but significant condition
info — informational
debug — debug-level messages

Filter logs by labels:

# filter by log level
>> dmesg -l warn

-----------------------------------------------------------------------------
[ 5.731996] platform eisa.0: EISA: Cannot allocate resource for mainboard
[ 5.741485] platform eisa.0: Cannot allocate resource for EISA slot 1
[ 5.749957] platform eisa.0: Cannot allocate resource for EISA slot 2
[ 5.758032] platform eisa.0: Cannot allocate resource for EISA slot 3
[ 5.766090] platform eisa.0: Cannot allocate resource for EISA slot 4
[ 5.774110] platform eisa.0: Cannot allocate resource for EISA slot 5
[ 5.782202] platform eisa.0: Cannot allocate resource for EISA slot 6
[ 5.790189] platform eisa.0: Cannot allocate resource for EISA slot 7
[ 5.798505] platform eisa.0: Cannot allocate resource for EISA slot 8
[ 97.074307] kauditd_printk_skb: 18 callbacks suppressed
[ 768.502491] clocksource: timekeeping watchdog on CPU0: Marking clocksource 'tsc' as unstable because the skew is too large:
[ 768.502492] clocksource: 'kvm-clock' wd_now: b61df70527 wd_last: b5ff72e7d3 mask: ffffffffffffffff
[ 768.502493] clocksource: 'tsc' cs_now: 1915e3e8a70 cs_last: 190f92c9366 mask: ffffffffffffffff



# Filter by multiple log level

>> dmesg -l warn,notice

Filter using “grep”

>>  dmesg | grep -i memory

-----------------------------------------------------------------------------
[ 0.016691] check: Scanning 1 areas for low memory corruption
[ 0.017233] ACPI: Reserving FACP table memory at [mem 0x7ffe1e29-0x7ffe1f1c]
[ 0.017234] ACPI: Reserving DSDT table memory at [mem 0x7ffe0040-0x7ffe1e28]
[ 0.017235] ACPI: Reserving FACS table memory at [mem 0x7ffe0000-0x7ffe003f]
[ 0.017236] ACPI: Reserving APIC table memory at [mem 0x7ffe1f1d-0x7ffe1f94]
[ 0.017237] ACPI: Reserving MCFG table memory at [mem 0x7ffe1f95-0x7ffe1fd0]
[ 0.017238] ACPI: Reserving WAET table memory at [mem 0x7ffe1fd1-0x7ffe1ff8]

uname

Uname is a Linux command-line utility that displays basic system information.

>> uname
Linux

Important options:

>> uname --help

-a, --all print all information
-s, --kernel-name print the kernel name
-n, --nodename print the network node hostname
-r, --kernel-release print the kernel release
-v, --kernel-version print the kernel version
-m, --machine print the machine hardware name
-p, --processor print the processor type (non-portable)
-i, --hardware-platform print the hardware platform (non-portable)
-o, --operating-system print the operating system
--version output version information and exit


>> uname -s
Linux

>> uname -n
node01

>> uname -r
5.4.0-131-generic

>> uname -v
#147-Ubuntu SMP Fri Oct 14 17:07:22 UTC 2022

>> uname -m
x86_64

>> uname -p
x86_64

>> uname -i
x86_64

>> uname -o
GNU/Linux

>> uname -a
Linux controlplane 5.4.0-131-generic #147-Ubuntu SMP Fri Oct 14 17:07:22 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

🖥 All Articles on Linux 👇

All Articles on Linux

5 stories

--

--

A new tech publication by Start it up (https://medium.com/swlh).

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store