Dmesg Kernel Messages - ryzendew/Linux-Tips-and-Tricks GitHub Wiki
DMESG Kernel Messages Troubleshooting for Beginners
Table of Contents
:pencil: What is dmesg?
dmesgdisplays kernel ring buffer messages- Shows hardware detection, driver loading, and kernel events
- Essential for troubleshooting hardware and boot issues
- Usually requires root privileges or proper permissions
What dmesg can do:
- Show kernel boot messages
- Display hardware detection events
- Show driver loading/unloading
- Reveal kernel errors and warnings
- Help troubleshoot hardware problems
:zap: Basic Commands
Show All Kernel Messages
sudo dmesg
What this does:
- Shows all kernel messages from boot to now
- Displays hardware detection, driver events, errors
- Very long output (usually piped to less or grep)
Note: On some systems, you may need sudo to read kernel messages.
Show Human-Readable Timestamps
sudo dmesg -T
What this does:
- Shows timestamps in human-readable format
- Easier to correlate with system events
- Shows when events occurred
Example output:
[Thu Nov 13 07:33:58 2025] Linux version 6.17.7-cachyos1.fc43.x86_64
[Thu Nov 13 07:33:58 2025] Command line: BOOT_IMAGE=/vmlinuz-6.17.7-cachyos1.fc43.x86_64
Show Only Errors
sudo dmesg -l err
What this does:
- Shows only error-level messages
- Filters out informational messages
- Useful for finding problems
Priority levels:
emerg- Emergencyalert- Alertcrit- Criticalerr- Errorwarn- Warningnotice- Noticeinfo- Infodebug- Debug
Show Only Warnings and Above
sudo dmesg -l warn
What this does:
- Shows warnings, errors, and critical messages
- Less verbose than all messages
- Good balance for troubleshooting
Show Last N Lines
sudo dmesg | tail -20
What this does:
- Shows the last 20 kernel messages
- Useful for recent events
- Quick check of recent activity
Clear Kernel Buffer
sudo dmesg -C
What this does:
- Clears the kernel ring buffer
- Useful for testing (seeing only new messages)
- Warning: You'll lose all previous messages
:mag: Filtering Messages
Search for Specific Text
sudo dmesg | grep -i error
What this does:
- Searches for "error" in kernel messages
- Case-insensitive with
-i - Useful for finding specific issues
Common searches:
sudo dmesg | grep -i "usb"
sudo dmesg | grep -i "network"
sudo dmesg | grep -i "fail"
Show Messages Since Boot
sudo dmesg -w
What this does:
- Shows new messages as they appear
- Like
tail -ffor kernel messages - Useful for monitoring in real-time
Exit with Ctrl+C
:bulb: Common Troubleshooting
Check Hardware Detection
sudo dmesg | grep -i "usb\|pci\|sata"
Shows USB, PCI, and SATA device detection.
Find Driver Issues
sudo dmesg | grep -i "driver\|module"
Shows driver loading and module information.
Check for Errors
sudo dmesg -l err
Shows only error-level messages.
View Boot Messages
sudo dmesg | head -50
Shows early boot messages.
:link: Related Commands
journalctl for Kernel Messages
journalctl -k
What this does:
- Shows kernel messages via systemd journal
- More features than dmesg
- Can filter by time, priority, etc.
See: Journalctl Troubleshooting Guide
:keyboard: Quick Reference
sudo dmesg # All messages
sudo dmesg -T # Human-readable timestamps
sudo dmesg -l err # Errors only
sudo dmesg -l warn # Warnings and above
sudo dmesg | tail -20 # Last 20 messages
sudo dmesg | grep -i error # Search for errors
sudo dmesg -w # Watch for new messages
sudo dmesg -C # Clear buffer
For system logs, see the Journalctl Troubleshooting Guide.