Write the kernel messages to standard output.
Show kernel messages
$ dmesg
-L
- 输出日志显示颜色
如果输出的日志是纯白或纯黑的,就会显得很不友善,想要colorful就可以加上-L选项:
$ dmesg -L
-l=...
- 只输出特定级别的信息
有的时候我们只要要error以及warning,不要别的等级的信息,可以使用如下命令:
$ dmesg --level=err,warn
level选项还可以填入别的等级,例如emerg、alert、crit、err、warn、notice、info、debug。
-T
- 显示时间戳
需要注意到的是,dmesg命令默认的时间显示是从开机到log记录的时间,说实话,这样对于人类来说真的不方便,我们需要时间:
$ dmesg -T
-X
- 显示级别
$ dmesg -x
# Show how much physical memory is available on this system:
$ dmesg | grep -i memory
# Show kernel messages 1 page at a time:
$ dmesg | less
# 只输出dmesg命令最后20行日志
$ dmesg | tail -20
# 实时监控dmesg日志输出
$ watch "dmesg | tail -20
-c
- 清空dmesg的日志
我们可以使用如下命令来清空dmesg的日志。该命令会清空dmesg环形缓冲区中的日志。但是你依然可以查看存储在‘/var/log/dmesg’文件中的日志。你连接任何的设备都会产生dmesg日志输出。
# 清空dmesg缓冲区日志
$ dmesg -c
-f
- 显示特定 facility 的日志
Restrict output to the given (comma-separated) list of facilities. For example:
$ dmesg --facility=daemon
This will print messages from system daemons only. For all supported facilities see the –help output.
Reference
- man dmesg
FEATURED TAGS
algorithm
algorithm-problem
architectural-pattern
architecture
aws
c#
cache-system
codis
concurrent-control
data-format
data-structure
database
debug
design
design-pattern
distributed-system
django
docker
engineering
engingeering
freebsd
git
golang
grafana
hackintosh
hardware
hexo
http
hugo
ios
iot
java
java-ee
javascript
kafka
kubernetes
linux
lock
macos
markdown
microservices
mysql
nas
network
network-programming
nginx
node.js
npm
oop
openwrt
operating-system
operating-systems
padavan
performance
programming
prometheus
protobuf
python
redis
router
security
shell
software-testing
spring
sql
truenas
ubuntu
vmware
vpn
windows
wmware
wordpress
zookeeper