首页 > 编程笔记 > Linux命令 阅读:4

Linux dmesg命令的用法(附带实例)

在系统启动过程中,内核还需要进行一次系统检测,这些内核检测信息会被记录在内存当中。我们是否可以查看内核检测信息呢?使用 dmesg 命令就可以查看这些信息,我们一般利用这个命令查看系统的硬件信息。

dmesg 命令的格式如下:
[root@localhost ~]# dmesg

例如:
[root@localhost ~]# dmesg | grep CPU
#查看CPU的信息
[    0.008759] smpboot: Allowing 128 CPUs, 127 hotplug CPUs
[    0.012280] setup_percpu: NR_CPUS:8192 nr_cpumask_bits:128 nr_cpu_ids:128 nr_node_ids:1
[    0.087928] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=128, Nodes=1
[    0.108295] rcu: RCU restricting CPUs from NR_CPUS=8192 to nr_cpu_ids=128.
[    0.113421] random: crng init done (trusting CPU's manufacturer)
[    0.133366] smpboot: CPU0: 12th Gen Intel(R) Core(TM) i9-12900H (family: 0x6, model: 0x9a, stepping: 0x3)
[    0.134302] core: CPUID marked event: 'cpu cycles' unavailable
[    0.134302] core: CPUID marked event: 'instructions' unavailable
[    0.134302] core: CPUID marked event: 'bus cycles' unavailable
[    0.134302] core: CPUID marked event: 'cache references' unavailable
[    0.134302] core: CPUID marked event: 'cache misses' unavailable
[    0.134302] core: CPUID marked event: 'branch instructions' unavailable
[    0.134302] core: CPUID marked event: 'branch misses' unavailable
[    0.145782] smp: Bringing up secondary CPUs ...
[    0.145786] smp: Brought up 1 node, 1 CPU
[    0.601995] intel_pstate: CPU model not supported

[root@localhost ~]# dmesg | grep eth0
[root@localhost ~]# dmesg | grep ens33
#查看第一块网卡的信息。通过eth0依然可以查询,能看到MAC地址、网卡型号等信息
#如果查看ens33,就可以看到1000Mbps网卡、全双工等网卡信息

相关文章