dmesg 命令

好用的Linux指令--dmesg的多种用法以及源码 它可以输出内核在启动过程中或运行过程中产生的各种消息,这些消息通常用于调试、诊断系统问题、查看硬件设备状态和跟踪内核日志。dmesg 输出的信息包括内核启动时的各种事件、硬件设备的加载、驱动程序的初始化、内核模块的加载、错误、警告信息等。消息级别:包括不同的日志级别,如信息(INFO)、警告(WARNING)、错误(ERROR)等。dmesg -l level:显示指定级别的日志消息(例如 -l err 只显示错误消息)。内核消息内容:内核生成的详细信息,如硬件检测、驱动加载、内存分配、错误日志等。 阅读详情

dmesg 这个命令,Linux下用的还是比较多的。现在来详细看一下:

Linux dmesg命令用于显示开机信息。
kernel会将开机信息存储在ring buffer中。您若是开机时来不及查看信息,可利用dmesg来查看。开机信息亦保存在/var/log目录中,名称为dmesg的文件里。
一、语法

dmesg [-cn][-s <缓冲区大小>]
二、选项

-c :显示信息后,清除ring buffer中的内容。
-s <缓冲区大小>:预设置为8196,刚好等于ring buffer的大小。
-n :设置记录信息的层级。

$ dmesg -h

Usage:
 dmesg [options]

Options:
 -C, --clear                 clear the kernel ring buffer
 -c, --read-clear            read and clear all messages
 -D, --console-off           disable printing messages to console
 -d, --show-delta            show time delta between printed messages
 -E, --console-on            enable printing messages to console
 -f, --facility <list>       restrict output to defined facilities
 -h, --help                  display this help and exit
 -k, --kernel                display kernel messages
 -l, --level <list>          restrict output to defined levels
 -n, --console-level <level> set level of messages printed to console
 -r, --raw                   print the raw message buffer
 -s, --buffer-size <size>    buffer size to query the kernel ring buffer
 -T, --ctime                 show human readable timestamp (could be
                             inaccurate if you have used SUSPEND/RESUME)
 -t, --notime                don't print messages timestamp
 -u, --userspace             display userspace messages
 -V, --version               output version information and exit
 -x, --decode                decode facility and level to readable string

Supported log facilities:
    kern - kernel messages
    user - random user-level messages
    mail - mail system
  daemon - system daemons
    auth - security/authorization messages
  syslog - messages generated internally by syslogd
     lpr - line printer subsystem
    news - network news subsystem

Supported log levels (priorities):
   emerg - system is unusable
   alert - action must be taken immediately
    crit - critical conditions
     err - error conditions
    warn - warning conditions
  notice - normal but significant condition
    info - informational
   debug - debug-level messages

三、实例

root@dm368-evm:/# dmesg
>Bad block table found at page 262080, version 0x01
Bad block table found at page 262016, version 0x01
nand_bbt: ECC error while reading bad block table
nand_read_bbt: Bad block at 0x00000ff00000
nand_read_bbt: Bad block at 0x00000ff20000
nand_read_bbt: Bad block at 0x00000ff40000
nand_read_bbt: Bad block at 0x00000ff60000
nand_read_bbt: Bad block at 0x00000ff80000
nand_read_bbt: Bad block at 0x00000ffa0000
nand_read_bbt: Bad block at 0x00000ffc0000
nand_read_bbt: Bad block at 0x00000ffe0000
Creating 5 MTD partitions on "davinci_nand.0":
0x000000000000-0x0000003c0000 : "bootloader"
0x0000003c0000-0x000000400000 : "params"
0x000000400000-0x000000820000 : "kernel"
0x000000820000-0x000008820000 : "filesystem"
0x000008820000-0x000020000000 : "zslf"
davinci_nand davinci_nand.0: controller rev. 2.3
UBI: attaching mtd3 to ubi0
UBI: physical eraseblock size:   131072 bytes (128 KiB)
UBI: logical eraseblock size:    126976 bytes
UBI: smallest flash I/O unit:    2048
UBI: VID header offset:          2048 (aligned 2048)
UBI: data offset:                4096
UBI: attached mtd3 to ubi0
UBI: MTD device name:            "filesystem"
UBI: MTD device size:            128 MiB
UBI: number of good PEBs:        1024
UBI: number of bad PEBs:         0
UBI: max. allowed volumes:       128
UBI: wear-leveling threshold:    4096
UBI: number of internal volumes: 1
UBI: number of user volumes:     1
UBI: available PEBs:             5
UBI: total number of reserved PEBs: 1019
UBI: number of PEBs reserved for bad PEB handling: 10
UBI: max/mean erase counter: 20/11
UBI: image sequence number: 0
UBI: background thread "ubi_bgt0d" started, PID 343
PPP generic driver version 2.4.2
PPP Deflate Compression module registered
PPP BSD Compression module registered
PPP MPPE Compression module registered
NET: Registered protocol family 24
tun: Universal TUN/TAP device driver, 1.6
tun: (C) 1999-2004 Max Krasnyansky <maxk@qualcomm.com>
console [netcon0] enabled
netconsole: network logging started
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
usbcore: registered new interface driver usbserial
USB Serial support registered for generic
usbcore: registered new interface driver usbserial_generic
usbserial: USB Serial Driver core
USB Serial support registered for GSM modem (1-port)
usbcore: registered new interface driver option
option: v0.7.2:USB Driver for GSM modems
usbcore: registered new interface driver usbtest
rtc-ds1307 1-0068: rtc core: registered ds1339 as rtc0
i2c /dev entries driver
Linux video capture interface: v2.00
ths7303 1-002c: chip found @ 0x58 (DaVinci I2C adapter)
ths7303 1-002c: ths7303 write failed
ths7303: probe of 1-002c failed with error -121
vpfe_init
vpfe-capture: vpss clock vpss_master enabled
vpfe-capture vpfe-capture: v4l2 device registered
vpfe-capture vpfe-capture: video device registered
dm365evm_enable_pca9543a
dm365evm_enable_pca9543a, status = -121
EVM: switch to HD imager video input
mt9p031 1-005d: Detected a MT9P031 chip ID 1801
mt9p031 1-005d: mt9p031 1-005d decoder driver registered !!
vpfe-capture vpfe-capture: v4l2 sub device mt9p031 registered
vpfe_register_ccdc_device: DM365 ISIF
DM365 ISIF is registered with vpfe.
af major#: 250, minor# 0
AF Driver initialized
aew major#: 249, minor# 0
AEW Driver initialized
###### osd_init ######
### VPBE OSD DRIVER INIT ###
<davinci_display_init>
Trying to register davinci display video device.
layer=c112d000,layer->video_dev=c112d170
Trying to register davinci display video device.
layer=c112d400,layer->video_dev=c112d570
davinci_init:DaVinci V4L2 Display Driver V1.0 loaded
</davinci_init>
watchdog watchdog: heartbeat 60 sec
davinci_mmc davinci_mmc.0: Using DMA, 4-bit mode
Advanced Linux Sound Architecture Driver Version 1.0.21.
No device for DAI tlv320aic3x
No device for DAI davinci-i2s
asoc: tlv320aic3x <-> davinci-i2s mapping ok
ALSA device list:
  #0: DaVinci EVM (tlv320aic3x)
TCP cubic registered
NET: Registered protocol family 17
Clocks: disable unused mmcsd1
Clocks: disable unused spi0
Clocks: disable unused spi1
Clocks: disable unused spi2
Clocks: disable unused spi3
Clocks: disable unused spi4
Clocks: disable unused pwm0
Clocks: disable unused pwm1
Clocks: disable unused pwm2
Clocks: disable unused pwm3
Clocks: disable unused timer1
Clocks: disable unused timer3
Clocks: disable unused emac
Clocks: disable unused voice_codec
Clocks: disable unused rto
Clocks: disable unused mjcp
davinci_emac_probe: using random MAC addr: 32:be:8d:46:68:be
emac-mii: probed
rtc-ds1307 1-0068: setting system clock to 2015-12-05 11:04:18 UTC (1449313458)
UBIFS: mounted UBI device 0, volume 0, name "rootfs"
UBIFS: file system size:   126341120 bytes (123380 KiB, 120 MiB, 995 LEBs)
UBIFS: journal size:       6348800 bytes (6200 KiB, 6 MiB, 50 LEBs)
UBIFS: media format:       w4/r0 (latest is w4/r0)
UBIFS: default compressor: lzo
UBIFS: reserved for root:  4952683 bytes (4836 KiB)
VFS: Mounted root (ubifs filesystem) on device 0:14.
Freeing init memory: 144K
udev: starting version 141
eth0: attached PHY driver [LXT971] (mii_bus:phy_addr=1:01, id=1378e2)
CMEMK module: built on Mar 24 2011 at 16:58:03
  Reference Linux version 2.6.32
  File /sdk/build/DVSDK_4_02/4_02_00_06/arago-install/arago-tmp/work/dm368-evm-none-linux-gnueabi/ti-linuxutils-1_2_26_01_02-r52d/linuxutils_2_26_01_02/packages/ti/sdo/linuxutils/cmem/src/module/cmemk.c
allocated heap buffer 0xc7000000 of size 0x4400000
heap fallback enabled - will try heap if pool buffer is not available
CMEM Range Overlaps Kernel Physical - allowing overlap
CMEM phys_start (0x1000) overlaps kernel (0x80000000 -> 0x83000000)
cmemk initialized
PHY: 1:01 - Link is Up - 100/Full
IRQK module: built on Mar 24 2011 at 16:58:17
  Reference Linux version 2.6.32
  File /sdk/build/DVSDK_4_02/4_02_00_06/arago-install/arago-tmp/work/dm368-evm-none-linux-gnueabi/ti-linuxutils-1_2_26_01_02-r52d/linuxutils_2_26_01_02/packages/ti/sdo/linuxutils/irq/src/module/irqk.c
irqk initialized
EDMAK module: built on Mar 24 2011 at 16:58:11
  Reference Linux version 2.6.32
  File /sdk/build/DVSDK_4_02/4_02_00_06/arago-install/arago-tmp/work/dm368-evm-none-linux-gnueabi/ti-linuxutils-1_2_26_01_02-r52d/linuxutils_2_26_01_02/packages/ti/sdo/linuxutils/edma/src/module/edmak.c
###### output_store ######
###### davinci_get_cur_encoder ######
<vpbe_encoder_enumoutput>
</vpbe_encoder_enumoutput>
<vpbe_encoder_enumoutput>
</vpbe_encoder_enumoutput>
VPBE Encoder de-initialized
###### vpbe_encoder_initialize ######
###### output is COMPOSITE,outindex is 0 ######
###### vpbe_encoder_setoutput ######
<vpbe_encoder_setoutput>
Setting output to Composite
Start of vpbe_encoder_setmode..
###### dm365 = 1 ######
###### mode_info->std is 1 ######
###### mode is NTSC ######
</vpbe_encoder_setmode>
</vpbe_encoder_setoutput>
VPBE Encoder initialized
###### 22VPBE Encoder initialized ######
###### vpbe_encoder_setoutput ######
<vpbe_encoder_setoutput>
Setting output to Component Video
Start of vpbe_encoder_setmode..
###### dm365 = 1 ######
###### mode_info->std is 1 ######
###### mode is 480P-60 ######
</vpbe_encoder_setmode>
</vpbe_encoder_setoutput>
<vpbe_encoder_getmode>
<vpbe_encoder_getmode/>
###### davinci_enc_set_output : next davinci_enc_set_mode_platform ######
###### davinci_enc_set_mode_platform : next davinci_enc_priv_setmode ######
###### output_show ######
###### davinci_enc_get_output ######
###### davinci_get_cur_encoder ######
<vpbe_encoder_getoutput>
</vpbe_encoder_getoutput>
###### mode_store ######
###### davinci_enc_get_mode ######
###### davinci_get_cur_encoder ######
<vpbe_encoder_getmode>
<vpbe_encoder_getmode/>
###### davinci_enc_set_mode ######
###### davinci_get_cur_encoder ######
Start of vpbe_encoder_setmode..
###### dm365 = 1 ######
###### mode_info->std is 1 ######
###### mode is 576P-50 ######
</vpbe_encoder_setmode>
<vpbe_encoder_getmode>
<vpbe_encoder_getmode/>
###### davinci_enc_set_mode : next davinci_enc_set_mode ######
###### davinci_enc_set_mode_platform : next davinci_enc_priv_setmode ######
###### mode_show ######
###### davinci_enc_get_mode ######
###### davinci_get_cur_encoder ######
<vpbe_encoder_getmode>
<vpbe_encoder_getmode/>
###### davinci_enc_get_mode ######
###### davinci_get_cur_encoder ######
<vpbe_encoder_getmode>
<vpbe_encoder_getmode/>
###### davinci_enc_get_mode ######
###### davinci_get_cur_encoder ######
<vpbe_encoder_getmode>
<vpbe_encoder_getmode/>
###### davinci_enc_set_mode ######
###### davinci_get_cur_encoder ######
Start of vpbe_encoder_setmode..
###### dm365 = 1 ######
###### mode_info->std is 1 ######
###### mode is 576P-50 ######
</vpbe_encoder_setmode>
<vpbe_encoder_getmode>
<vpbe_encoder_getmode/>
###### davinci_enc_set_mode : next davinci_enc_set_mode ######
###### davinci_enc_set_mode_platform : next davinci_enc_priv_setmode ######
###### davinci_enc_get_mode ######
###### davinci_get_cur_encoder ######
<vpbe_encoder_getmode>
<vpbe_encoder_getmode/>
###### davinci_enc_get_mode ######
###### davinci_get_cur_encoder ######
<vpbe_encoder_getmode>
<vpbe_encoder_getmode/>
###### davinci_enc_get_mode ######
###### davinci_get_cur_encoder ######
<vpbe_encoder_getmode>
<vpbe_encoder_getmode/>
davinci_resizer davinci_resizer.2: RSZ_G_CONFIG:0:1:124
davinci_previewer davinci_previewer.2: ipipe_set_preview_config
davinci_previewer davinci_previewer.2: ipipe_set_preview_config
vpfe-capture vpfe-capture: IPIPE Chained
vpfe-capture vpfe-capture: Resizer present
dm365evm_enable_pca9543a
dm365evm_enable_pca9543a, status = -121
EVM: switch to HD imager video input
######vpfe_dev->current_subdev->is_camera.
-----Exposure time = 2f2############
v4l2_device_call_until_err sdinfo->grp_id : 4.
-----Exposure time = 2f2
vpfe-capture vpfe-capture: width = 1280, height = 720, bpp = 1
vpfe-capture vpfe-capture: adjusted width = 1280, height = 720, bpp = 1, bytesperline = 1280, sizeimage = 1382400
vpfe-capture vpfe-capture: width = 1280, height = 720, bpp = 1
vpfe-capture vpfe-capture: adjusted width = 1280, height = 720, bpp = 1, bytesperline = 1280, sizeimage = 1382400
ipipe_set_resizer, resizer - A enabled

四、与管道一起使用

    参看:Linux系统中‘dmesg’命令处理故障和收集系统信息的7种用法

(1)列出加载到内核中的所有驱动

我们可以使用如‘more’。 ‘tail’, ‘less ’或者‘grep’文字处理工具来处理‘dmesg’命令的输出。由于dmesg日志的输出不适合在一页中完全显示,因此我们使用管道(pipe)将其输出送到more或者less命令单页显示。

[root@tecmint.com ~]# dmesg | more
[root@tecmint.com ~]# dmesg | less

输出:
[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Initializing cgroup subsys cpuacct
[    0.000000] Linux version 3.11.0-13-generic (buildd@aatxe) (gcc version 4.8.1 (Ubuntu/Linaro 4.8.1-10ubuntu8) ) #20-Ubuntu SMP Wed Oct 23 17:26:33 UTC 2013
(Ubuntu 3.11.0-13.20-generic 3.11.6)
[    0.000000] KERNEL supported cpus:
[    0.000000]   Intel GenuineIntel
[    0.000000]   AMD AuthenticAMD
[    0.000000]   NSC Geode by NSC
[    0.000000]   Cyrix CyrixInstead
[    0.000000]   Centaur CentaurHauls
[    0.000000]   Transmeta GenuineTMx86
[    0.000000]   Transmeta TransmetaCPU
[    0.000000]   UMC UMC UMC UMC
[    0.000000] e820: BIOS-provided physical RAM map:
[    0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable
[    0.000000] BIOS-e820: [mem 0x00000000000f0000-0x00000000000fffff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000000100000-0x000000007dc08bff] usable
[    0.000000] BIOS-e820: [mem 0x000000007dc08c00-0x000000007dc5cbff] ACPI NVS
[    0.000000] BIOS-e820: [mem 0x000000007dc5cc00-0x000000007dc5ebff] ACPI data
[    0.000000] BIOS-e820: [mem 0x000000007dc5ec00-0x000000007fffffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000e0000000-0x00000000efffffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000fec00000-0x00000000fed003ff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000fed20000-0x00000000fed9ffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000fee00000-0x00000000feefffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000ffb00000-0x00000000ffffffff] reserved
[    0.000000] NX (Execute Disable) protection: active
.....

2、 列出所有被检测到的硬件

要显示所有被内核检测到的硬盘设备,你可以使用‘grep’命令搜索‘sda’关键词,如下:

[root@tecmint.com ~]# dmesg | grep sda

[    1.280971] sd 2:0:0:0: [sda] 488281250 512-byte logical blocks: (250 GB/232 GiB)
[    1.281014] sd 2:0:0:0: [sda] Write Protect is off
[    1.281016] sd 2:0:0:0: [sda] Mode Sense: 00 3a 00 00
[    1.281039] sd 2:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[    1.359585]  sda: sda1 sda2 < sda5 sda6 sda7 sda8 >
[    1.360052] sd 2:0:0:0: [sda] Attached SCSI disk
[    2.347887] EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts: (null)
[   22.928440] Adding 3905532k swap on /dev/sda6.  Priority:-1 extents:1 across:3905532k FS
[   23.950543] EXT4-fs (sda1): re-mounted. Opts: errors=remount-ro
[   24.134016] EXT4-fs (sda5): mounted filesystem with ordered data mode. Opts: (null)
[   24.330762] EXT4-fs (sda7): mounted filesystem with ordered data mode. Opts: (null)
[   24.561015] EXT4-fs (sda8): mounted filesystem with ordered data mode. Opts: (null)

注解: ‘sda’表示第一块 SATA硬盘,‘sdb’表示第二块SATA硬盘。若想查看IDE硬盘搜索‘hda’或‘hdb’关键词。
3、只输出dmesg命令的前20行日志

在‘dmesg’命令后跟随‘head’命令来显示开始几行,‘dmesg | head -20′命令将显示开始的前20行。

[root@tecmint.com ~]# dmesg | head  -20

[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Initializing cgroup subsys cpuacct
[    0.000000] Linux version 3.11.0-13-generic (buildd@aatxe) (gcc version 4.8.1 (Ubuntu/Linaro 4.8.1-10ubuntu8) ) #20-Ubuntu SMP Wed Oct 23 17:26:33 UTC 2013 (Ubuntu 3.11.0-13.20-generic 3.11.6)
[    0.000000] KERNEL supported cpus:
[    0.000000]   Intel GenuineIntel
[    0.000000]   AMD AuthenticAMD
[    0.000000]   NSC Geode by NSC
[    0.000000]   Cyrix CyrixInstead
[    0.000000]   Centaur CentaurHauls
[    0.000000]   Transmeta GenuineTMx86
[    0.000000]   Transmeta TransmetaCPU
[    0.000000]   UMC UMC UMC UMC
[    0.000000] e820: BIOS-provided physical RAM map:
[    0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable
[    0.000000] BIOS-e820: [mem 0x00000000000f0000-0x00000000000fffff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000000100000-0x000000007dc08bff] usable
[    0.000000] BIOS-e820: [mem 0x000000007dc08c00-0x000000007dc5cbff] ACPI NVS
[    0.000000] BIOS-e820: [mem 0x000000007dc5cc00-0x000000007dc5ebff] ACPI data
[    0.000000] BIOS-e820: [mem 0x000000007dc5ec00-0x000000007fffffff] reserved

 

4、只输出dmesg命令最后20行日志

在‘dmesg’命令后跟随‘tail’命令(‘ dmesg | tail -20’)来输出‘dmesg’命令的最后20行日志,当你插入可移动设备时它是非常有用的。

[root@tecmint.com ~]# dmesg | tail -20

parport0: PC-style at 0x378, irq 7 [PCSPP,TRISTATE]
ppdev: user-space parallel port driver
EXT4-fs (sda1): mounted filesystem with ordered data mode
Adding 2097144k swap on /dev/sda2.  Priority:-1 extents:1 across:2097144k
readahead-disable-service: delaying service auditd
ip_tables: (C) 2000-2006 Netfilter Core Team
nf_conntrack version 0.5.0 (16384 buckets, 65536 max)
NET: Registered protocol family 10
lo: Disabled Privacy Extensions
e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None
Slow work thread pool: Starting up
Slow work thread pool: Ready
FS-Cache: Loaded
CacheFiles: Loaded
CacheFiles: Security denies permission to nominate security context: error -95
eth0: no IPv6 routers present
type=1305 audit(1398268784.593:18630): audit_enabled=0 old=1 auid=4294967295 ses=4294967295 res=1
readahead-collector: starting delayed service auditd
readahead-collector: sorting
readahead-collector: finished

5、搜索包含特定字符串的被检测到的硬件

由于‘dmesg’命令的输出实在太长了,在其中搜索某个特定的字符串是非常困难的。因此,有必要过滤出一些包含‘usb’ ‘dma’ ‘tty’ ‘memory’等字符串的日志行。grep 命令 的‘-i’选项表示忽略大小写。

[root@tecmint.com log]# dmesg | grep -i usb
[root@tecmint.com log]# dmesg | grep -i dma
[root@tecmint.com log]# dmesg | grep -i tty
[root@tecmint.com log]# dmesg | grep -i memory

输出:
[    0.000000] Scanning 1 areas for low memory corruption
[    0.000000] initial memory mapped: [mem 0x00000000-0x01ffffff]
[    0.000000] Base memory trampoline at [c009b000] 9b000 size 16384
[    0.000000] init_memory_mapping: [mem 0x00000000-0x000fffff]
[    0.000000] init_memory_mapping: [mem 0x37800000-0x379fffff]
[    0.000000] init_memory_mapping: [mem 0x34000000-0x377fffff]
[    0.000000] init_memory_mapping: [mem 0x00100000-0x33ffffff]
[    0.000000] init_memory_mapping: [mem 0x37a00000-0x37bfdfff]
[    0.000000] Early memory node ranges
[    0.000000] PM: Registered nosave memory: [mem 0x0009f000-0x000effff]
[    0.000000] PM: Registered nosave memory: [mem 0x000f0000-0x000fffff]
[    0.000000] please try 'cgroup_disable=memory' option if you don't want memory cgroups
[    0.000000] Memory: 2003288K/2059928K available (6352K kernel code, 607K rwdata, 2640K rodata, 880K init, 908K bss, 56640K reserved, 1146920K highmem)
[    0.000000] virtual kernel memory layout:
[    0.004291] Initializing cgroup subsys memory
[    0.004609] Freeing SMP alternatives memory: 28K (c1a3e000 - c1a45000)
[    0.899622] Freeing initrd memory: 23616K (f51d0000 - f68e0000)
[    0.899813] Scanning for low memory corruption every 60 seconds
[    0.946323] agpgart-intel 0000:00:00.0: detected 32768K stolen memory
[    1.360318] Freeing unused kernel memory: 880K (c1962000 - c1a3e000)
[    1.429066] [drm] Memory usable by graphics device = 2048M

6、清空dmesg缓冲区日志

我们可以使用如下命令来清空dmesg的日志。该命令会清空dmesg环形缓冲区中的日志。但是你依然可以查看存储在‘/var/log/dmesg’文件中的日志。你连接任何的设备都会产生dmesg日志输出。

[root@tecmint.com log]# dmesg -c

7、实时监控dmesg日志输出

在某些发行版中可以使用命令‘tail -f /var/log/dmesg’来实时监控dmesg的日志输出。

[root@tecmint.com log]# watch "dmesg | tail -20"

结论: dmesg命令在系统dmesg记录实时更改或产生的情况下是非常有用的。你可以使用man dmesg来获取更多关于dmesg的信息。
---------------------  
作者:聚优致成  
来源:CSDN  
原文:https://blog.csdn.net/qq_29350001/article/details/79062948  
版权声明:本文为博主原创文章,转载请附上博文链接!

Linux下修改dmesg命令缓冲区ring buffer的大小 dmesg 阅读详情

相关推荐

Linux中dmesg命令的详细解析

dmesg命令不需要任何参数,当直接在终端中输入dmesg时,它将显示内核环缓冲区中的所有消息。这些消息包括内核启动信息、硬件检测与初始化信息、设备驱动程序信息以及其他与内核相关的重要消息。dmesg命令是一个功能强大的工具,用于显示和控制内核环缓冲区的消息。dmesg命令还可以与其他命令结合使用,以过滤和搜索特定类型的消息。例如,可以使用grep命令来仅显示与特定关键字相关的消息。通过使用dmesg命令,您可以轻松查看和分析Linux系统中的内核消息。示例4:显示内核缓冲区中的消息并清除缓冲区。

InjeProgram的博客 785

dmesg 总结

1.dmesg介绍 在dmesg里我们可以查看到开机信息,printk产生的信息等。若研究内核代码,在代码中插入printk函数,然后通过dmesg观察是一个很好地方法。   2.dmesg输出含义 dmesg 输出的数字含义是什么,纠结了一会儿,下面给出解释 终端输入dmesg,可以看到每行最开始显示的是一个综括号,里面的数字为timestamp,时间戳,该时间指示

abcd1f2的专栏 3万+

【Linux系列】Linux中dmesg命令详解

dmesg’命令对设备故障的诊断是非常重要的。在‘dmesg’命令的帮助下进行硬件的连接或断开连接操作时,我们可以看到硬件的检测或者断开连接的信息。‘dmesg’命令在多数基于Linux和Unix的操作系统中都可以使用。今天在调试硬件设备时,设备API报错但是没有打印信息,可以通过dmesg命令查看,应该是硬件将相关API使用报错写到了这个ring buffer中。记录在里面,以备后面使用。

CSDN明星博主,认证博客专家,视频、Matlab领域优质创作者。 1万+

Linux必会100个命令(五十三)dmesg命令

dmesg是英文display message缩写. 命令用于显示开机信息. kernel会将开机信息存储在ring buffer中.如果开机时来不及察看信息,可以用dmesg来查看.开机信息也会保存在/var/log/dmesg文件中。

bigwood99的博客 5670

RDD2022 数据格式转换与清洗

Rdd2022数据集,是关于道路损伤的数据集,与rdd2020相比增加了两万多张图片但是由于格式不能被yolo直接使用且其中有大量的图片没有符合要求的标注,特写此文章记录数据清洗与格式化的过程。

蓝胖子的博客 9980

ICG cell如何通过Latch结构消除与门clock gating中的glitch?

本文深入解析了ICG Cell如何利用Latch结构解决传统与门时钟门控中的毛刺问题。通过将电平敏感锁存器与门控与门结合,ICG Cell将使能信号的变化严格限制在时钟低电平的安全窗口内采样和锁存,从而在时钟有效沿期间提供稳定的控制信号,从根本上消除了因信号延迟不同步而产生的glitch,确保了门控时钟的纯净与电路功能的可靠性。

weixin_29234423的博客 478

Linux命令之dmesg命令

Linux dmesg(英文全称:display message)命令用于显示开机信息。kernel 会将开机信息存储在 ring buffer 中。您若是开机时来不及查看信息,可利用 dmesg 来查看。开机信息亦保存在 /var/log 目录中,名称为 dmesg 的文件里。

月生的静心苑 5万+

网络可视化工具netron详细安装流程

netron安装目录1.netron 简介2.不同操作系统下的安装使用方式2.1 在线版本:只要有浏览器就可以2.2 不同操作系统安装使用3.netron支持的网络框架4.netron测试演示 1.netron 简介 在实际的项目中,经过会遇到各种网络模型,需要我们快速去了解网络结构。如果单纯的去看模型文件,脑海中很难直观的浮现网络的架构。 这时,就可以使用netron可视化工具,可以清晰的看到每一层的输入输出,网络总体的架构,而且支持各种不同网络框架,简单好用。 2.不同操作系统下的安装使用方式 2.1

江南研习社 12万+

Linux命令:dmesg命令

dmesg 命令在 Linux 系统中用于显示和控制内核的环形缓冲区,内核在启动过程中会将信息存储在这个缓冲区中。使用 dmesg 可以有效诊断机器硬件故障或者添加硬件出现的问题。另外,使用 dmesg 可以确定服务器安装了哪些硬件。每次系统重启,系统都会检查所有硬件并将信息记录下来。执行/bin/dmesg 命令可以查看该记录,开机信息会保存在/var/log/dmesg文件里。以上的案例及案例中的输出内容只是内核信息中的一小部分,更多内容需要我们继续深入学习。

dl_11的博客 8520

usb gadget uvc driver的code分析

uvc的linux driver分为host侧和gadget侧两个driver。host侧的driver在v4l2框架下,而设备侧的driver在usb/gadget文件夹下。gadget侧的uvc driver,利用v4l2框架去注册video_device,向应用层提供调用接口。同时,它完成v4l2 video buffer拷贝到usb request下的buffer下,然后利用uvc实现的协

lintwins的专栏 1万+

YOLOV12融合MSDA多尺度空洞注意力:突破尺度限制的科研实践指南

MSDA通过多尺度空洞注意力的设计,为YOLOV12突破尺度检测瓶颈提供了有效方案。从原理理解到代码实现,再到集成调优,每一步都是科研中“解决实际问题”的具体实践。如果你在实验中发现某类尺度目标的检测仍有不足,可以尝试结合数据增强(如随机缩放、多尺度训练)来强化模型对尺度变化的鲁棒性。科研的价值在于不断解决真实难题,希望这份指南能真正帮你在目标检测的尺度感知领域找到新的突破点,祝你在科研探索中持续收获新的见解与成果。

FJN110的博客 248

dmesg命令

dmesg命令

qq_43934844的博客 2485

【MATLAB】嵌入式PID控制参数整定与优化

本文提出了一种基于MATLAB仿真的嵌入式PID参数优化方法,解决了传统人工试凑法效率低、适应性差的问题。通过建立一阶滞后被控对象模型,对比分析了不同PID参数组合的性能表现,筛选出最优参数。仿真结果表明,优化后的PID参数能有效降低超调量(从传统方法的显著超调降至接近0%),缩短调节时间,提高稳态精度。最终将优化算法部署到STM32平台,实现了"仿真整定-参数优化-嵌入式落地"的完整开发流程。该方法显著提升了嵌入式系统的响应速度和控制精度,为工业控制应用提供了标准化解决方案。

unber的博客 52

Linux命令dmesg介绍和使用

dmesg命令是Linux系统下一个非常常用的命令。其用于输出Linux系统启动时的内核环境信息,主要用于问题诊断和系统调试。使用dmesg命令可以查看各个系统组件启动时所输出的信息,例如CPU、内存、设备驱动、网络、文件系统等等。通过dmesg命令可以获取(system log)系统日志记录的所有信息,但只有内核数据,可以帮助诊断系统故障、调试应用程序、排除内核相关的问题和监控系统运行状态等等。dmesg 命令是一个非常强大且广泛使用的命令,在 Linux 命令行中经常会用到。

captain 8798

linux v3h平台开发系列详解(GMSL摄像头篇):1.12 解串器MAX96712输出4 lane 变 2 lane的配置

本文详细介绍了在Linux v3h平台上,针对Max96712解串器进行MIPI 4lane到2lane配置。内容包括串行器解串器介绍、链路框架、硬件连接、以及软件寄存器如何配值和一些问题的解决方法。

xian18809311584的博客 1099

【同等学力】01-逻辑符号表达

F(x): x是确诊者,G(x):x有症状F(x): x是老人,G(x):x是宠物,L(x,y): x喜欢y。

super_mochi1 1898

dmesg命令详解

dmesg 命令的使用范例 下面我们展示一些最负盛名的‘dmesg’命令工具以及其实际使用举例。‘dmesg’命令的使用语法如下。 1. 列出加载到内核中的所有驱动 grep’文字处理工具来处理‘dmesg’命令的输出。由于dmesg日志的输出不适合在一页中完全显示,因此我们使用管道(pipe)将其输出送到more或者less命令单页显示。 root@tecmintcomdmesgmore root@tecmintcomdmesgless ]Initia...

一口Linux的专栏 1万+

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

Linux dmesg 命令

Linux 系统中的 dmesg 命令是查看内核日志的强大工具,它能实时显示硬件检测、驱动状态和系统事件等关键信息。本文详细介绍了 dmesg 的工作原理、安装方法、常用参数选项,并提供了从基础到高级的使用实例,包括日志过滤、实时监控、错误排查等实用技巧。

gongwanzhang的博客 1164

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

linux dmesg命令

dmesg命令-->用来显示开机信息, kernel会将开机信息存储在ring buffer中。开机时来不及查看信息,可利用dmesg来查看。开机信息亦保存在/var/log/dmesg 在‘dmesg’命令的帮助下进行硬件的连接或断开连接操作时,我们可以看到硬件的检测或者断开连接的信息。 描述: dmesg is used to examine or control t...

WuDong 503

dmesg 命令的完整指南

是 Linux 系统调试的。

C/C++ 4251

linux命令 dmesg_如何在Linux上使用dmesg命令

linux命令 dmesgFatmawati Achmad Zaenuri/ShutterstockFatmawati Achmad Zaenuri / Shutterstock The dmesg command lets you peer into the hidden world of the Linux startup processes. Review and monitor hardw...

culintai3473的博客 1150
上一篇: 浅谈内核的Makefile、Kconfig和.config文件
下一篇: snprintf的使用
春已暖花已开
博客等级 码龄9年 168粉丝 39原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址