dmesg Linux Command
Prints the kernel ring buffer messages (boot-time and hardware diagnostics).
What does dmesg do?
Prints the kernel ring buffer messages (boot-time and hardware diagnostics).
Syntax
dmesg [options]Practical example
dmesg | tail -20Questions about dmesg
How do I see kernel messages?
Use `dmesg` to display kernel ring buffer messages. This includes boot messages, hardware detection, and driver errors.
How do I see the last 20 kernel messages?
Use `dmesg | tail -20` to see only the most recent kernel messages without scrolling through all output.
How do I watch kernel messages in real time?
Use `dmesg -w` or `tail -f /var/log/dmesg` to watch kernel messages as they are generated.
How do I see hardware errors with dmesg?
Use `dmesg | grep -i error` to filter kernel messages for error conditions, especially hardware-related issues.
How do I clear the kernel ring buffer?
Use `sudo dmesg -c` to clear the ring buffer. This is useful after reviewing messages you no longer need.
How do I see USB device messages?
Use `dmesg | grep -i usb` to see messages related to USB device connections and disconnections.
How do I see disk errors?
Use `dmesg | grep -i 'error|fail|disk'` to find disk-related errors and failures in kernel messages.
How do I see timestamped kernel messages?
Use `dmesg -T` to show human-readable timestamps instead of seconds since boot.
Related System Information
vmstatReports virtual memory statistics including CPU, memory, and I/O.
lsmodLists all currently loaded kernel modules.
freeDisplays the amount of free and used system memory (RAM and swap).
modinfoDisplays detailed information about a specific kernel module.
lsusbLists all USB devices connected to the system.
envDisplays all current environment variables.