Linux shell编程学习笔记57:lshw命令 获取cpu设备信息插图

0 前言

在Linux中,获取cpu信息的命令很多,除了我们已经研究的 cat /proc/cpuinfo、lscpu、nproc、hwinfo –cpu 命令,还有 lshw命令

1 lshw命令的功能

 lshw命令源自英文list hardware,即列出系统的硬件信息,这些硬件包括cpu、内存、硬盘、pci设备等等。今天我们主要是使用 lshw命令查询cpu信息。

[purpleendurer @ bash ~ ]lshw --help
Hardware Lister (lshw) - B.02.17
usage: lshw [-format] [-options ...]
       lshw -version

	-version        print program version (B.02.17)

format can be
	-html           output hardware tree as HTML
	-xml            output hardware tree as XML
	-short          output hardware paths
	-businfo        output bus information

options can be
	-class CLASS    only show a certain class of hardware
	-C CLASS        same as '-class CLASS'
	-c CLASS        same as '-class CLASS'
	-disable TEST   disable a test (like pci, isapnp, cpuid, etc. )
	-enable TEST    enable a test (like pci, isapnp, cpuid, etc. )
	-quiet          don't display status
	-sanitize       sanitize output (remove sensitive information like serial numbers, etc.)
	-numeric        output numeric IDs (for PCI, USB, etc.)

[purpleendurer @ bash ~ ]

Linux shell编程学习笔记57:lshw命令 获取cpu设备信息插图(1)

2 使用lshw命令查询cpu信息

2.1 lshw -C cpu:查询cpu信息

[purpleendurer @ bash ~ ]lshw -C cpu
WARNING: you should run this program as super-user.
  *-cpu:0                 
       physical id: 7
       bus info: cpu@0
       size: 2600MHz
       capacity: 2600MHz
       capabilities: fp asimd evtstrm aes pmull sha1 sha2 crc32 cpufreq
  *-cpu:1
       physical id: 8
       bus info: cpu@1
       size: 2600MHz
       capacity: 2600MHz
       capabilities: fp asimd evtstrm aes pmull sha1 sha2 crc32 cpufreq
  *-cpu:2
       physical id: 9
       bus info: cpu@2
       size: 2600MHz
       capacity: 2600MHz
       capabilities: fp asimd evtstrm aes pmull sha1 sha2 crc32 cpufreq
  *-cpu:3
       physical id: a
       bus info: cpu@3
       size: 2600MHz
       capacity: 2600MHz
       capabilities: fp asimd evtstrm aes pmull sha1 sha2 crc32 cpufreq
WARNING: output may be incomplete or inaccurate, you should run this program as super-user.
[purpleendurer @ bash ~ ]

Linux shell编程学习笔记57:lshw命令 获取cpu设备信息插图(2)

 

这是关于某个 CPU 的信息。具体含义如下:

序号信息含义
1-cpu:0CPU编号:表示这是第一个 CPU
2physical id: 7物理 ID是 7
3bus info: cpu@0总线信息
4size: 2600MHz尺寸是 2600MHz,即主频为 2.6GHz
5capacity: 2600MHz容量也是 2600MHz,即主频为 2.6GHz
6capabilities: fp asimd evtstrm aes pmull sha1 sha2 crc32 cpufreq功能:包括 fp(浮点运算)、asimd(SIMD指令集)、evtstrm(事件跟踪)、aes(AES加密指令集)、pmull(多项式乘法)、sha1(SHA-1散列函数加速)、sha2(SHA-2散列函数加速)、crc32(CRC32校验)、cpufreq(CPU频率调节)

2.2 lshw -C cpu -short:查询和显示简短cpu信息

[purpleendurer @ bash ~ ]lshw -C cpu -short
WARNING: you should run this program as super-user.
H/W path    Device      Class      Description
==============================================
/0/7                    processor  
/0/8                    processor  
/0/9                    processor  
/0/a                    processor  
WARNING: output may be incomplete or inaccurate, you should run this program as super-user.
[purpleendurer @ bash ~ ]

Linux shell编程学习笔记57:lshw命令 获取cpu设备信息插图(3)

2.3 lshw -C cpu -short:查询并以xml格式显示cpu信息

[purpleendurer @ bash ~ ]lshw -C cpu -xml
WARNING: you should run this program as super-user.







  
   7
   cpu@0
   2600000000
   2600000000
   
    Floating point instructions
    Advanced SIMD
    Event stream
    AES instructions
    PMULL instruction
    SHA1 instructions
    SHA2 instructions
    CRC extension
    CPU Frequency scaling
   
  
  
   8
   cpu@1
   2600000000
   2600000000
   
    Floating point instructions
    Advanced SIMD
    Event stream
    AES instructions
    PMULL instruction
    SHA1 instructions
    SHA2 instructions
    CRC extension
    CPU Frequency scaling
   
  
  
   9
   cpu@2
   2600000000
   2600000000
   
    Floating point instructions
    Advanced SIMD
    Event stream
    AES instructions
    PMULL instruction
    SHA1 instructions
    SHA2 instructions
    CRC extension
    CPU Frequency scaling
   
  
  
   a
   cpu@3
   2600000000
   2600000000
   
    Floating point instructions
    Advanced SIMD
    Event stream
    AES instructions
    PMULL instruction
    SHA1 instructions
    SHA2 instructions
    CRC extension
    CPU Frequency scaling
   
  

WARNING: output may be incomplete or inaccurate, you should run this program as super-user.
[purpleendurer @ bash ~ ]

 Linux shell编程学习笔记57:lshw命令 获取cpu设备信息插图(4)

2.4 lshw -C cpu -html:查询并以htm格式显示cpu信息

[purpleendurer @ bash ~ ]lshw -C cpu -html
WARNING: you should run this program as super-user.






  .first {font-weight: bold; margin-left: none; padding-right: 1em;vertical-align: top; }
  .second {padding-left: 1em; width: 100%; vertical-align: center; }
  .id {font-family: monospace;}
  .indented {margin-left: 2em; border-left: dotted thin #dde; padding-bottom: 1em; }
  .node {border: solid thin #ffcc66; padding: 1em; background: #ffffcc; }
  .node-unclaimed {border: dotted thin #c3c3c3; padding: 1em; background: #fafafa; color: red; }
  .node-disabled {border: solid thin #f55; padding: 1em; background: #fee; color: gray; }

gxxc-ce3000f






        
    
id:cpu:0
physical id: 7
bus info: cpu@0
size: 2600MHz
capacity: 2600MHz
capabilities: fp asimd evtstrm aes pmull sha1 sha2 crc32 cpufreq
id:cpu:1
physical id: 8
bus info: cpu@1
size: 2600MHz
capacity: 2600MHz
capabilities: fp asimd evtstrm aes pmull sha1 sha2 crc32 cpufreq
id:cpu:2
physical id: 9
bus info: cpu@2
size: 2600MHz
capacity: 2600MHz
capabilities: fp asimd evtstrm aes pmull sha1 sha2 crc32 cpufreq
id:cpu:3
physical id: a
bus info: cpu@3
size: 2600MHz
capacity: 2600MHz
capabilities: fp asimd evtstrm aes pmull sha1 sha2 crc32 cpufreq
WARNING: output may be incomplete or inaccurate, you should run this program as super-user. [purpleendurer @ bash ~ ]

Linux shell编程学习笔记57:lshw命令 获取cpu设备信息插图(5)

本站无任何商业行为
个人在线分享 » Linux shell编程学习笔记57:lshw命令 获取cpu设备信息
E-->