Skip to content

Instantly share code, notes, and snippets.

@chiehwen
Last active August 29, 2015 14:05
Show Gist options
  • Select an option

  • Save chiehwen/d4852a0aa7a2f6b6c3d4 to your computer and use it in GitHub Desktop.

Select an option

Save chiehwen/d4852a0aa7a2f6b6c3d4 to your computer and use it in GitHub Desktop.

顯示所有被核心偵測到的硬碟裝置

$ dmesg | grep sda

sda - SATA, hda - IDE

輸出前 20 行

$ dmesg | head -20

輸出最後 20 行,插入 USB 等移動裝置時很方便

$ dmesg | tail -20

-i 表示要忽略大小寫

$ dmesg | grep -i usb
$ dmesg | grep -i dma
$ dmesg | grep -i tty
$ dmesg | grep -i memory

清空 dmesg 的日誌 清空緩衝區的日誌,但您能可查看 /var/log/dmesg 下的日誌

$ dmesg -c

即時監控 dmesg 的輸出

watch "dmesg | tail -20"

延伸閱讀及參考資料

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment