dmesg(英文全称:display message)命令用于显示开机信息。
开机信息亦保存在 /var/log 目录中,名称为 dmesg 的文件里。
一、语法
dmesg [选项]
二、选项
-C, --clear 清除内核环形缓冲区(ring butter)
-c, --read-clear 读取并清除所有消息
-D, --console-off 禁止向终端打印消息
-E, --console-on 启用向终端打印消息
-F, --file <文件> 用 文件 代替内核日志缓冲区
-f, --facility <列表> 将输出限制为定义的设施
-H, --human 易读格式输出
-k, --kernel 显示内核消息
-L, --color[=<when>] colorize messages (auto, always or never)
默认启用颜色
-l, --level <列表> 限制输出级别
-n, --console-level <级别> 设置打印到终端的消息级别
-P, --nopager 不将输出通过管道传递给分页程序
-p, --force-prefix force timestamp output on each line of multi-line messages
-r, --raw 打印原生消息缓冲区
--noescape don't escape unprintable character
-S, --syslog 强制使用 syslog(2) 而非 /dev/kmsg
-s, --buffer-size <大小> 查询内核环形缓冲区所用的缓冲区大小,预设置为 8196,刚好等于 ring buffer 的大小
-u, --userspace 显示用户空间消息
-w, --follow 等待新消息
-W, --follow-new wait and print only new messages
-x, --decode 将设施和级别解码为可读的字符串
-d, --show-delta 显示打印消息之间的时间差
-e, --reltime 以易读格式显示本地时间和时间差
-T, --ctime 显示易读的时间戳(可能不准确!)
-t, --notime 不显示任何消息的时间戳
--time-format <格式> 以指定格式显示时间戳:
[delta|reltime|ctime|notime|iso]
挂起/恢复会使 ctime 和 iso 时间戳不精确。
--since <time> display the lines since the specified time
--until <time> display the lines until the specified time
-h, --help 显示此帮助
-V, --version 显示版本
支持的日志设施:
kern - 内核消息
user - 随机的用户级消息
mail - 邮件系统
daemon - 系统守护进程
auth - 安全/认证消息
syslog - syslogd 内部生成的消息
lpr - 行打印机子系统
news - 网络新闻子系统
支持的日志级别(优先级):
emerg - 系统无法使用
alert - 操作必须立即执行
crit - 紧急条件
err - 错误条件
warn - 警告条件
notice - 正常但重要的条件
info - 信息
debug - 调试级别的消息
三、实例
1.显示开机信息
dmesg | less
2.指定级别
dmesg -l err,warn
3.指定类别
dmesg -f daemon
4.显示颜色
dmesg -L
5.显示时间
dmesg -T
6.查找特定内容
dmesg | grep -i memory