设为首页收藏本站

LUPA开源社区

 找回密码
 注册
文章 帖子 博客

检查和收集 Linux 硬件信息的 7 个命令

2014-5-15 09:33| 发布者: 红黑魂| 查看: 6694| 评论: 0|来自: 开源中国编译

摘要: 在Linux系统中,有许多命令可用于查询主机的硬件信息。一些命令只针对特定的硬件组件,比如CPU、内存,一些命令可以查询多个硬件信息。这篇文章只是简单的让每个人了解查询硬件信息的基本命令使用,包括lscpu、hwinf ...

在Linux系统中,有许多命令可用于查询主机的硬件信息。一些命令只针对特定的硬件组件,比如CPU、内存,一些命令可以查询多个硬件信息。

这篇文章只是简单的让每个人了解查询硬件信息的基本命令使用,包括lscpu、hwinfo、lshw、lspci、lsblk、lsusb等等。

1. lscpu用于查询CPU信息

01[root@devops ~]# lscpu
02Architecture:          x86_64
03CPU op-mode(s):        32-bit, 64-bit
04Byte Order:            Little Endian
05CPU(s):                1
06On-line CPU(s) list:   0
07Thread(s) per core:    1
08Core(s) per socket:    1
09CPU socket(s):         1
10NUMA node(s):          1
11Vendor ID:             GenuineIntel
12CPU family:            6
13Model:                 45
14Stepping:              7
15CPU MHz:               2194.842
16BogoMIPS:              4389.68
17Hypervisor vendor:     Xen
18Virtualization type:   full
19L1d cache:             32K
20L1i cache:             32K
21L2 cache:              256K
22L3 cache:              15360K
23NUMA node0 CPU(s):     0


2. lshw显示硬件信息表

这个命令应用普遍,它可通过个人需求而列出多种不同的硬件参数:CPU、内存、硬盘、USB控制器、lshw卡片等等,本质上就是从/proc目录不同文件中中提取对应的硬件信息。

按照下面的步骤去安装lshw工具,然后就可以使用了。

1 wget http://ezix.org/software/files/lshw-B.02.14.tar.gz
2 tar -zxvf lshw-B.02.14.tar.gz
3 cd lshw-B.02.14
4 make && make install

示例:

01[root@devops lshw-B.02.14]# lshw -short
02H/W path          Device       Class      Description
03=====================================================
04                               system     HVM domU
05/0                             bus        Motherboard
06/0/0                           memory     96KiB BIOS
07/0/1                           processor  Intel(R) Xeon(R) CPU E5-2430 0 @ 2.20GHz
08/0/2                           memory     System Memory
09/0/2/0                         memory     512MiB DIMM RAM
10/0/2/1                         memory     512MiB DIMM RAM
11/0/3                           memory     96KiB BIOS
12/0/4                           processor  CPU
13/0/5                           memory     System Memory
14/0/6                           memory     
15/0/7                           memory     
16/0/100                         bridge     440FX - 82441FX PMC [Natoma]
17/0/100/1                       bridge     82371SB PIIX3 ISA [Natoma/Triton II]
18/0/100/1.1        scsi1        storage    82371SB PIIX3 IDE [Natoma/Triton II]
19/0/100/1.1/0.0.0  /dev/cdrom1  disk       SCSI CD-ROM
20/0/100/1.2                     bus        82371SB PIIX3 USB [Natoma/Triton II]
21/0/100/1.2/1      usb1         bus        UHCI Host Controller
22/0/100/1.2/1/2                 input      QEMU USB Tablet
23/0/100/1.3                     bridge     82371AB/EB/MB PIIX4 ACPI
24/0/100/2                       display    GD 5446
25/0/100/3                       generic    Xen Platform Device
26/1                eth0         network    Ethernet interface
27/2                eth1         network    Ethernet interface
28[root@devops lshw-B.02.14]#

3. hwinfo-硬件信息

hwinfo类似于lshw,也能查询硬件信息,且应用广泛。它也能输出多个硬件部分的详细或者简要信息,但是不同的是有时hwinfo比lshw的信息更详细。

默认情况下,Linux系统没有安装hwinfo工具,所以你需要按照以下步骤自己安装:

CentOS 6

1#rpm -Uvh http://mirror.symnds.com/distributions/gf/el/6/gf/x86_64/gf-release-6-6.gf.el6.noarch.rpm
2#yum list hwinfo
3#yum install hwinfo

CentOS 5

1#rpm -Uvh http://mirror.symnds.com/distributions/gf/el/5/gf/x86_64/gf-release-5-6.gf.el5.noarch.rpm
2#yum list hwinfo
3#yum install hwinfo
01[root@devops tmp]# rpm -Uvh http://mirror.symnds.com/distributions/gf/el/6/gf/x86_64/gf-release-6-6.gf.el6.noarch.rpm
02Retrieving http://mirror.symnds.com/distributions/gf/el/6/gf/x86_64/gf-release-6-6.gf.el6.noarch.rpm
03warning: /var/tmp/rpm-tmp.m2mMAO: Header V4 RSA/SHA1 Signature, key ID 13a4d2a9: NOKEY
04Preparing...                ########################################### [100%]
05   1:gf-release             ########################################### [100%]
06[root@devops tmp]# yum list hwinfo
07Loaded plugins: fastestmirror
08Loading mirror speeds from cached hostfile
09 * base: mirrors.aliyun.com
10 * extras: mirrors.aliyun.com
11 * updates: mirrors.aliyun.com
12gf                                                                                                    
13 
14 00:00     
15gf/primary_db                                                                                     
16 
17 00:00     
18Available Packages
19hwinfo.x86_64
20[root@devops tmp]# yum list hwinfo
21Loaded plugins: fastestmirror
22Loading mirror speeds from cached hostfile
23 * base: mirrors.aliyun.com
24 * extras: mirrors.aliyun.com
25 * updates: mirrors.aliyun.com
26gf                                                                                                   
27 
28 00:00     
29gf/primary_db                                                                                          
30 
31 00:00     
32Available Packages
33hwinfo.x86_64                                                20.2-1.gf.el6
01[root@devops tmp]# yum install hwinfo
02Loaded plugins: fastestmirror
03Loading mirror speeds from cached hostfile
04 * base: mirrors.aliyun.com
05 * extras: mirrors.aliyun.com
06 * updates: mirrors.aliyun.com
07Setting up Install Process
08Resolving Dependencies
09--> Running transaction check
10---> Package hwinfo.x86_64 0:20.2-1.gf.el6 will be installed
11.....

示例:

01[root@devops tmp]# hwinfo -short
02oops: don't know what to do with "short"
03[root@devops tmp]# hwinfo --short
04cpu:                                                            
05                       Intel(R) Xeon(R) CPU E5-2430 0 @ 2.20GHz, 2194 MHz
06keyboard:
07  /dev/input/event3    AT Translated Set 2 keyboard
08  /dev/ttyS0           serial console
09mouse:
10  /dev/input/mice      Adomax QEMU USB Tablet
11  /dev/input/mice      Macintosh mouse button emulation
12  /dev/input/mice      ImExPS/2 Generic Explorer Mouse
13graphics card:
14                       Cirrus Logic GD 5446
15storage:
16                       Intel 82371SB PIIX3 IDE [Natoma/Triton II]
17                       Xen Virtual Storage 0
18                       Xen Virtual Storage 1
19                       Xen Virtual Storage 2
20network:
21  eth0                 Xen Virtual Ethernet Card 0
22  eth1                 Xen Virtual Ethernet Card 1
23network interface:
24  lo                   Loopback network interface
25  eth0                 Ethernet network interface
26  eth1                 Ethernet network interface
27disk:
28  /dev/xvda            Disk
29  /dev/xvdb            Disk
30partition:
31  /dev/xvda1           Partition
32  /dev/xvdb1           Partition
33cdrom:
34  /dev/sr0             QEMU DVD-ROM
35usb controller:
36                       Qumranet Qemu virtual machine
37bios:
38                       BIOS
39bridge:
40                       Qumranet Qemu virtual machine
41                       Qumranet Qemu virtual machine
42                       Qumranet Qemu virtual machine
43hub:
44                       Linux 2.6.32-279.el6.x86_64 uhci_hcd UHCI Host Controller
45memory:
46                       Main Memory
47unknown:
48                       FPU
49                       DMA controller
50                       PIC
51                       Timer
52                       Keyboard controller
53                       XenSource Xen Platform Device
54[root@devops tmp]#




酷毙

雷人

鲜花

鸡蛋

漂亮
  • 快毕业了,没工作经验,
    找份工作好难啊?
    赶紧去人才芯片公司磨练吧!!

最新评论

关于LUPA|人才芯片工程|人才招聘|LUPA认证|LUPA教育|LUPA开源社区 ( 浙B2-20090187 浙公网安备 33010602006705号   

返回顶部