The dmesg command can be used to view the boot messages printed by Linux kernel. The Linux kernel maintains a ring buffer (default size 16KB) to hold boot-time messages printed using printk() function call in kernel code. The dmesg command can be used to control the ring buffer as well.

[neo@techpulp ~]$ dmesg
Linux version 2.6.23.15-137.fc8 (mockbuild@xenbuilder2.fedora.redhat.com) (gcc version 4.1.2 20070925 (Red Hat 4.1.2-33)) #1 SMP Sun Feb 10 17:48:34 EST 2008
BIOS-provided physical RAM map:
BIOS-e820: 0000000000000000 - 000000000009dc00 (usable)
BIOS-e820: 000000000009dc00 - 00000000000a0000 (reserved)
BIOS-e820: 00000000000d2000 - 0000000000100000 (reserved)
BIOS-e820: 0000000000100000 - 000000007bf10000 (usable)
BIOS-e820: 000000007bf10000 - 000000007bf19000 (ACPI data)
....
....
NET: Registered protocol family 31
Bluetooth: HCI device and connection manager initialized
Bluetooth: HCI socket layer initialized
Bluetooth: L2CAP ver 2.8
Bluetooth: L2CAP socket layer initialized
Bluetooth: RFCOMM socket layer initialized
Bluetooth: RFCOMM TTY layer initialized
Bluetooth: RFCOMM ver 1.8

If the size of kernel’s internal ring buffer is larger than the default size, you should pass that size to dmesg command using -s option. The following example shows how to view at max 32KB size of kernel log messages.

[neo@techpulp ~]$ dmesg -s32768

The “dmesg -c” can be used to clear the ring buffer that clears all existing messages.

[neo@techpulp ~]$ dmesg -c

The Linux kernel prints the boot messages with different log levels. You can set the log level at which the kernel logs are printed on console. The following example sets log level to 1. However all the messages are buffered and this controls the type of messages that are printed on console. If you are using graphical desktops like KDE or GNOME, using this command may not appear to make any change. You can see the kernel boot messages on console if the system is used in text mode.

[neo@techpulp ~]$ dmesg -n1

The Linux kernel provides proc interface to access log messages printed by it. The file /proc/kmsg contains all the log messages.