dmesg
行程與系統
用法
sudo dmesg -T | tail讀取核心的環形緩衝區,磁碟或 USB 出問題後第一個該看的地方;緩衝區大小固定,舊行早被擠掉了,而現在多數發行版要 root(macOS 用 `log show`)。
常用選項
| 選項 | 含義 |
|---|---|
| -T | Human-readable timestamps instead of seconds since boot. |
| -w | Follow new kernel messages as they appear. |
| -l err,warn | Filter by level. |
| -H | Paged, colourised, relative-time output. |
| --since "5 min ago" | Time-bounded output (newer util-linux). |
範例
sudo dmesg -T | tail -50Read what the kernel said about a disk or USB device just now.
dmesg -wWatch live while you plug something in.
log show --last 10mThe macOS equivalent; its dmesg exists but shows almost nothing.
看什麼在跑、什麼在吃機器。先弄清是什麼,再決定殺不殺。
怎麼看
- 方括號 [ ] 表示這部分可以不寫。
- 省略號 … 表示可以寫多個。
- 選項區分大小寫——有些命令裡 -r 和 -R 不是一回事。
常見問題
Q. dmesg 是做什麼的?
讀取核心的環形緩衝區,磁碟或 USB 出問題後第一個該看的地方;緩衝區大小固定,舊行早被擠掉了,而現在多數發行版要 root(macOS 用 `log show`)。
Q. 怎麼寫?
sudo dmesg -T | tail —— 方括號表示可以省略的部分。
Q. 值得記的選項有幾個?
這裡列了 5 個,完整列表在 man dmesg。這條命令屬於行程與系統。
相關命令
man 手冊: man dmesg