← 返回命令列表

Linux command

dmesg 命令

安全

权限或系统影响较大,执行前请核对目标。

常用示例

Example

sudo dmesg

Example

sudo dmesg -l err

Follow

sudo dmesg -w

Example

sudo dmesg -T

Example

sudo dmesg -H

Colorize

sudo dmesg -L

Example

sudo dmesg -f kern

说明

dmesg prints and controls the kernel ring buffer, which contains messages from the kernel including hardware detection, driver loading, and system events. It is essential for debugging hardware and driver issues.

参数

-l, --level level
Restrict output to specified log levels (emerg, alert, crit, err, warn, notice, info, debug)
-f, --facility facility
Restrict output to specified facilities (kern, user, mail, daemon, etc.)
-T, --ctime
Print human-readable timestamps
-H, --human
Enable human-readable output with colors and timestamps
-w, --follow
Wait for new messages (like tail -f)
-L, --color
Colorize output
-c, --read-clear
Clear the ring buffer after printing
-C, --clear
Clear the ring buffer without printing
-n, --console-level level
Set level of messages printed to console
-k, --kernel
Print kernel messages only
-u, --userspace
Print userspace messages only
--time-format _format_
Timestamp format: ctime, reltime, delta, iso, raw
--since _time_
Display records since the specified time
--until _time_
Display records until the specified time
-J, --json
Output in JSON format
-t, --notime
Do not print kernel timestamps
-r, --raw
Print raw message buffer with log-level prefixes
-x, --decode
Decode facility and level to human-readable prefixes

FAQ

What is the dmesg command used for?

dmesg prints and controls the kernel ring buffer, which contains messages from the kernel including hardware detection, driver loading, and system events. It is essential for debugging hardware and driver issues.

How do I run a basic dmesg example?

Run `sudo dmesg` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -l, --level level do in dmesg?

Restrict output to specified log levels (emerg, alert, crit, err, warn, notice, info, debug)