🛠️ Command: dmesg (Display Message)
The dmesg command is used to examine or control the kernel ring buffer. When your computer boots up, the kernel (the core of your OS) loads drivers and initializes hardware, printing status messages as it goes. dmesg allows you to read those messages.
1. The "Why"
For an Arch Linux user with a custom hardware setup , dmesg is the first place you go when something isn't working:
- Hardware Troubleshooting: If you plug in your vivo y29 or a USB drive and it doesn't show up,
dmesgwill tell you if the kernel even saw the device. - Driver Issues: Check if your NVIDIA drivers or AMD firmware loaded correctly or if they threw an error during boot.
- System Stability: Detect hardware failures like failing disk sectors, CPU overheating, or memory (RAM) errors.
- Debugging: If you are developing the Preader app or working with Java and the system freezes,
dmesgmight show an "OOM-killer" (Out of Memory) message.
2. How it Works
The kernel logs messages to a fixed-size buffer in memory. Because it is a "ring" buffer, once it gets full, the oldest messages are overwritten by new ones.
3. Essential Flags for Power Users
| Flag | Purpose | Use Case |
|---|---|---|
-w |
Follow | Real-time monitoring. Run this, then plug in a device to see what happens. |
-H |
Human-readable | Enables colors and a pager (like less) for easier reading. |
-T |
Timestamps | Converts the default "seconds since boot" format into a real date and time. |
-l [level] |
Level Filter | Only show certain types of messages (e.g., err, crit, warn). |
4. Practical Examples for Your Workflow
A. Checking for Hardware Errors
To find everything the kernel flagged as an error:
dmesg -l err
B. Troubleshooting USB/Smartphone Connections
If your vivo y29 isn't being recognized for Android debugging:
- Run
dmesg -w. - Unplug and replug the phone.
- Look for messages about "New USB device found" or "Device not responding."
C. Checking Graphics/NVIDIA Info
Verify your GPU is being handled correctly:
dmesg | grep -i nvidia
D. Identifying Disk Problems
If your SSD or HDD is acting slow or your Arch partitions are mounting as read-only:
dmesg | grep -i "sda" # or nvme
5. dmesg vs. journalctl -k
On modern Arch Linux (which uses systemd), you have two ways to see kernel logs:
dmesg: Directly reads the kernel buffer. It’s fast and works even if the logging service isn't fully started.journalctl -k: Shows the same kernel logs but stored in the systemd journal. This allows you to look at logs from previous boots, whichdmesgcannot do (it clears on restart).
6. Pro-Tips
- Pipe to Less: The output of
dmesgis usually very long. Usedmesg | lessto scroll through it. - Clearing the Buffer: If you want to clear old messages so you can focus on new ones:
sudo dmesg -c. - Arch Linux Context: If you're configuring Hyprland and your screen flickers, check
dmesgfor "GPU hang" or "DRM" (Direct Rendering Manager) errors. - Tutorial Tip: If you're writing a tutorial on fixing Android USB debugging, always tell your readers to check
dmesgfirst—it saves hours of guesswork.
7. Summary Reference
| Goal | Command |
|---|---|
| View all logs | dmesg |
| View with real clock time | dmesg -T |
| Live monitor | dmesg -w |
| Show only errors | dmesg -n 3 or dmesg -l err |