--- title: dmesg โ€” check kernel messages date: 2026-10-18 time: 12:00 model: admin category: programs author_type: human summary: Command that checks hardware, driver, and OOM messages left by the kernel. Essential for diagnosing unexplained reboots. tags: program, server log recording and analysis, dmesg --- **๐Ÿ’ฌ "dmesg command"** dmesg displays **kernel ring buffer** messages. Disk errors, network link issues, and OOM kills are recorded here. Because it is separate from user-space application logs, you should review it together when troubleshooting unexplained problems. - **Concept**: Shows kernel messages in chronological order. - **Left**: Kernel time in the format [ 12.345678] (seconds elapsed since boot). - **Contents**: Drivers, disk I/O errors, OOM killer, link status, and more. - **-T**: Converts to human-readable actual time. ## Commonly used options | Option | Description | | --- | --- | | -T | Convert timestamps to actual time | | -l err,warn | Show only specific levels | | -k | Show only kernel messages | | -w / --follow | Follow new messages in real time | ## 3 essential command combinations - `dmesg -T | tail -50` โ€” Check recent kernel messages - `dmesg -T | grep -i -E 'oom|killed process'` โ€” Check whether OOM kills occurred - `dmesg -T | grep -i -E 'error|fail|i/o'` โ€” Find hardware and I/O errors **๐Ÿ’ฌ "Show me an example of safely reverting this command"** Here are situations commonly encountered on live production servers, organized in order. ### Step 1 ยท Check recent messages View recent logs related to boot and devices. ``` dmesg -T | tail -50 ``` ### Step 2 ยท Check for OOM Check whether a process was killed due to insufficient memory. ``` dmesg -T | grep -i -E 'oom|killed process' ``` ### Step 3 ยท Check disk errors Check for I/O errors. ``` dmesg -T | grep -i -E 'i/o error|medium error|ata' ``` ## How to use this in practice ### 1. Process suddenly dies **Situation** โ€” An app process terminates without warning. ``` dmesg -T | grep -i -E 'oom|killed process' ``` **Result** โ€” If you see the message Out of memory: Killed process, the OOM killer terminated the process. **Point** โ€” Also check memory usage, and adjust swap or memory limits if needed. ### 2. Unexplained reboot **Situation** โ€” There is a record that the server rebooted in the early morning. ``` dmesg -T | head -30 ``` **Result** โ€” In the early boot messages, check hardware initialization and traces of the previous shutdown. **Point** โ€” When used together with journalctl --list-boots, you can identify the exact reboot time. ## Important notes - The ring buffer has a limited size, so old messages disappear. Use journal/rsyslog for permanent retention. - Kernel time alone makes it hard to know the actual time, so use -T. - Some distributions restrict dmesg access with kernel.dmesg_restrict. ## Actual output This is the result of checking for OOM kills and disk I/O errors. ![dmesg command output: kernel OOM and I/O errors](https://games.aidebatehub.com/assets/dmesg-demo.png) Live production server --- Source (HTML): https://games.aidebatehub.com/programs/linux/logs/dmesg.html This file is an auto-generated Markdown twin of the DevHub document.