Howto在Linux上查看cpu信息

Howto在Linux上查看cpu信息

一台服务器的性能高不高就看CPU好不好

那么在Linux中如何查看CPU的信息呢?

这里给出了3种查看方式。
先来看看第一种方式

查看cpu信息
第一种查看cpu信息方式
命令: cat /proc/cpuinfo
示例:

[root@localhost ~]# cat /proc/cpuinfo 
processor        : 0
vendor_id        : GenuineIntel
cpu family       : 6
model            : 142
model name       : Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
stepping         : 9
microcode        : 0xb4
cpu MHz          : 2712.006
cache size       : 3072 KB
physical id      : 0
siblings         : 2
core id          : 0
cpu cores        : 2
apicid           : 0
initial apicid   : 0
fpu              : yes
fpu_exception    : yes
cpuid level      : 22
wp               : yes
flags            : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc cpuid tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single pti ssbd ibrs ibpb stibp fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid mpx rdseed adx smap clflushopt xsaveopt xsavec xsaves arat md_clear flush_l1d arch_capabilities
bugs             : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit srbds mmio_stale_data retbleed gds
bogomips         : 5424.01
clflush size     : 64
cache_alignment  : 64
address sizes    : 43 bits physical, 48 bits virtual
power management:

这个命令列出了很多的信息,目前我们只需要了解以下几个参数即可
1、processor :0 表示第0个核cpu。
上面只截取了一个核的信息。如果有多个核会显示多个信息,只是processor的值不一样。
这里问一个问题,再创建虚拟机的时候我们选择了4核。
那么,在执行命令后最后一个processor的值应该是几呢?

2、model name 就是cpu型号了,可以看到我的CPU型号是Intel® Core™ i5-7200U,因为这是个虚拟机用的是宿主机的cpu型号。

除了cat /proc/cpuinfo可以查看cpu信息还有一个命令可以查看cpu信息

第二种查看cpu信息方式
命令:lscpu
示例:

[root@localhost ~]# lscpu 
架构:                   x86_64
  CPU 运行模式:         32-bit, 64-bit
  Address sizes:         43 bits physical, 48 bits virtual
  字节序:               Little Endian
CPU:                     4
  在线 CPU 列表:        0-3
厂商 ID:                GenuineIntel
  BIOS Vendor ID:        GenuineIntel
  型号名称:             Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
    BIOS Model name:     Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
    CPU 系列:           6
    型号:               142
    每个核的线程数:     1
    每个座的核数:       2
    座:                 2
    步进:               9
    BogoMIPS:           5424.01
    标记:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdt
                         scp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc cpuid tsc_known_freq pni pclmulqdq ssse3 fma cx16 pci
                         d sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch cpuid_fa
                         ult invpcid_single pti ssbd ibrs ibpb stibp fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid mpx rdseed adx smap clflushopt xsa
                         veopt xsavec xsaves arat md_clear flush_l1d arch_capabilities
Virtualization features: 
  超管理器厂商:         VMware
  虚拟化类型:           完全
Caches (sum of all):     
  L1d:                   128 KiB (4 instances)
  L1i:                   128 KiB (4 instances)
  L2:                    1 MiB (4 instances)
  L3:                    6 MiB (2 instances)
NUMA:                    
  NUMA 节点:            1
  NUMA 节点0 CPU:       0-3
Vulnerabilities:         
  Gather data sampling:  Unknown: Dependent on hypervisor status
  Itlb multihit:         KVM: Mitigation: VMX unsupported
  L1tf:                  Mitigation; PTE Inversion
  Mds:                   Mitigation; Clear CPU buffers; SMT Host state unknown
  Meltdown:              Mitigation; PTI
  Mmio stale data:       Mitigation; Clear CPU buffers; SMT Host state unknown
  Retbleed:              Mitigation; IBRS
  Spec store bypass:     Mitigation; Speculative Store Bypass disabled via prctl
  Spectre v1:            Mitigation; usercopy/swapgs barriers and __user pointer sanitization
  Spectre v2:            Mitigation; IBRS, IBPB conditional, STIBP disabled, RSB filling, PBRSB-eIBRS Not affected
  Srbds:                 Unknown: Dependent on hypervisor status
  Tsx async abort:       Not affected

lscpu 查看CPU信息的时候,除了CPU型号外,还列出了该CPU的架构和缓存信息
比如上面的CPU架构是x86_64,一缓存128KiB、二级缓存1MiB、三级缓存6MiB

还有一个命令可以查看CPU信息
第三种查看cpu信息方式
命令:lshw -c cpu
示例:

root@encoder:~# lshw -c cpu
  *-cpu:0                   
       description: CPU
       product: Intel(R) Xeon(R) Gold 5218 CPU @ 2.30GHz
       vendor: Intel Corp.
       physical id: 9
       bus info: cpu@0
       version: 6.85.7
       slot: CPU0
       size: 1216MHz
       capacity: 4GHz
       width: 64 bits
       clock: 100MHz
       capabilities: lm fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp x86-64 constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 invpcid_single ssbd mba ibrs ibpb stibp ibrs_enhanced fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req pku ospke avx512_vnni md_clear flush_l1d arch_capabilities cpufreq
       configuration: cores=16 enabledcores=16 microcode=83899139 threads=32
  *-cpu:1
       description: CPU
       product: Intel(R) Xeon(R) Gold 5218 CPU @ 2.30GHz
       vendor: Intel Corp.
       physical id: 13
       bus info: cpu@1
       version: 6.85.7
       slot: CPU1
       size: 2392MHz
       capacity: 4GHz
       width: 64 bits
       clock: 100MHz
       capabilities: lm fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp x86-64 constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 invpcid_single ssbd mba ibrs ibpb stibp ibrs_enhanced fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req pku ospke avx512_vnni md_clear flush_l1d arch_capabilities cpufreq
       configuration: cores=16 enabledcores=16 microcode=83899139 threads=32

通过上面的3个命令都可以查看CPU信息,但是查看到的信息又有所差别。
这个可以根据自己的需求和习惯选择使用命令。

你还有其他方式查看CPU的信息么?

  • 10
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

运维0到1

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值