检查和收集 Linux 硬件信息的 7 个命令 【已翻译100%】

简介:

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

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

1. lscpu用于查询CPU信息

[root@devops ~]# lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                1
On-line CPU(s) list:   0
Thread(s) per core:    1
Core(s) per socket:    1
CPU socket(s):         1
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 45
Stepping:              7
CPU MHz:               2194.842
BogoMIPS:              4389.68
Hypervisor vendor:     Xen
Virtualization type:   full
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              15360K
NUMA node0 CPU(s):     0
AI 代码解读
2. lshw显示硬件信息表
AI 代码解读

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

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

wget http://ezix.org/software/files/lshw-B.02.14.tar.gz
tar -zxvf lshw-B.02.14.tar.gz
cd lshw-B.02.14
make && make install
AI 代码解读

示例:

[root@devops lshw-B.02.14]# lshw -short
H/W path          Device       Class      Description
=====================================================
                               system     HVM domU
/0                             bus        Motherboard
/0/0                           memory     96KiB BIOS
/0/1                           processor  Intel(R) Xeon(R) CPU E5-2430 0 @ 2.20GHz
/0/2                           memory     System Memory
/0/2/0                         memory     512MiB DIMM RAM
/0/2/1                         memory     512MiB DIMM RAM
/0/3                           memory     96KiB BIOS
/0/4                           processor  CPU
/0/5                           memory     System Memory
/0/6                           memory     
/0/7                           memory     
/0/100                         bridge     440FX - 82441FX PMC [Natoma]
/0/100/1                       bridge     82371SB PIIX3 ISA [Natoma/Triton II]
/0/100/1.1        scsi1        storage    82371SB PIIX3 IDE [Natoma/Triton II]
/0/100/1.1/0.0.0  /dev/cdrom1  disk       SCSI CD-ROM
/0/100/1.2                     bus        82371SB PIIX3 USB [Natoma/Triton II]
/0/100/1.2/1      usb1         bus        UHCI Host Controller
/0/100/1.2/1/2                 input      QEMU USB Tablet
/0/100/1.3                     bridge     82371AB/EB/MB PIIX4 ACPI
/0/100/2                       display    GD 5446
/0/100/3                       generic    Xen Platform Device
/1                eth0         network    Ethernet interface
/2                eth1         network    Ethernet interface
[root@devops lshw-B.02.14]#
AI 代码解读

3. hwinfo-硬件信息

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

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

CentOS 6

#rpm -Uvh http://mirror.symnds.com/distributions/gf/el/6/gf/x86_64/gf-release-6-6.gf.el6.noarch.rpm
#yum list hwinfo
#yum install hwinfo
CentOS 5
AI 代码解读
#rpm -Uvh http://mirror.symnds.com/distributions/gf/el/5/gf/x86_64/gf-release-5-6.gf.el5.noarch.rpm
#yum list hwinfo
#yum install hwinfo
[root@devops tmp]# rpm -Uvh http://mirror.symnds.com/distributions/gf/el/6/gf/x86_64/gf-release-6-6.gf.el6.noarch.rpm
Retrieving http://mirror.symnds.com/distributions/gf/el/6/gf/x86_64/gf-release-6-6.gf.el6.noarch.rpm
warning: /var/tmp/rpm-tmp.m2mMAO: Header V4 RSA/SHA1 Signature, key ID 13a4d2a9: NOKEY
Preparing...                ########################################### [100%]
   1:gf-release             ########################################### [100%]
[root@devops tmp]# yum list hwinfo
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
gf                                                                                                    

 00:00     
gf/primary_db                                                                                     

 00:00     
Available Packages
hwinfo.x86_64
[root@devops tmp]# yum list hwinfo
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
gf                                                                                                   

 00:00     
gf/primary_db                                                                                          

 00:00     
Available Packages
hwinfo.x86_64                                                20.2-1.gf.el6
AI 代码解读
[root@devops tmp]# yum install hwinfo
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package hwinfo.x86_64 0:20.2-1.gf.el6 will be installed
.....
AI 代码解读

示例:

[root@devops tmp]# hwinfo -short
oops: don't know what to do with "short"
[root@devops tmp]# hwinfo --short
cpu:                                                            
                       Intel(R) Xeon(R) CPU E5-2430 0 @ 2.20GHz, 2194 MHz
keyboard:
  /dev/input/event3    AT Translated Set 2 keyboard
  /dev/ttyS0           serial console
mouse:
  /dev/input/mice      Adomax QEMU USB Tablet
  /dev/input/mice      Macintosh mouse button emulation
  /dev/input/mice      ImExPS/2 Generic Explorer Mouse
graphics card:
                       Cirrus Logic GD 5446
storage:
                       Intel 82371SB PIIX3 IDE [Natoma/Triton II]
                       Xen Virtual Storage 0
                       Xen Virtual Storage 1
                       Xen Virtual Storage 2
network:
  eth0                 Xen Virtual Ethernet Card 0
  eth1                 Xen Virtual Ethernet Card 1
network interface:
  lo                   Loopback network interface
  eth0                 Ethernet network interface
  eth1                 Ethernet network interface
disk:
  /dev/xvda            Disk
  /dev/xvdb            Disk
partition:
  /dev/xvda1           Partition
  /dev/xvdb1           Partition
cdrom:
  /dev/sr0             QEMU DVD-ROM
usb controller:
                       Qumranet Qemu virtual machine
bios:
                       BIOS
bridge:
                       Qumranet Qemu virtual machine
                       Qumranet Qemu virtual machine
                       Qumranet Qemu virtual machine
hub:
                       Linux 2.6.32-279.el6.x86_64 uhci_hcd UHCI Host Controller
memory:
                       Main Memory
unknown:
                       FPU
                       DMA controller
                       PIC
                       Timer
                       Keyboard controller
                       XenSource Xen Platform Device
[root@devops tmp]#
AI 代码解读

4. lspci

lsppci命令可列出PCI总线的信息以及连接到PCI总线上的设备信息,比如VGA适配器、SATA控制器、其他模块等等。lspci工具是pciutils包的一部分,所以在安装lspci之前,你需要安装pciutils包。

安装pciutils包使用下面的命令:

#yum install pciutils
[root@devops tmp]# yum install pciutils
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package pciutils.x86_64 0:3.1.10-2.el6 will be installed
--> Processing Dependency: pciutils-libs = 3.1.10-2.el6 for package: pciutils-3.1.10-2.el6.x86_64
--> Running transaction check
---> Package pciutils-libs.x86_64 0:3.1.4-11.el6 will be updated
---> Package pciutils-libs.x86_64 0:3.1.10-2.el6 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

Installing:
 pciutils                         x86_64                    3.1.10-2.el6               

      85 k
Updating for dependencies:
 pciutils-libs                    x86_64                    3.1.10-2.el6                 

      34 k

.....  

Dependency Updated:
  pciutils-libs.x86_64 0:3.1.10-2.el6                                                                            

Complete!
AI 代码解读

示例:

[root@devops tmp]# lspci 
00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma](rev 02)
00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II]
00:01.1 IDE interface: Intel Corporation 82371SB PIIX3 IDE [Natoma/Triton II]
00:01.2 USB controller: Intel Corporation 82371SB PIIX3 USB [Natoma/Triton II](rev 01)
00:01.3 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 01)
00:02.0 VGA compatible controller: Cirrus Logic GD 5446
00:03.0 Unassigned class [ff80]: XenSource, Inc. Xen Platform Device (rev 01)
[root@devops tmp]#
AI 代码解读

**5. lsusb-列出USB总线信息
**
这个命令可列出USB控制器的设备信息。

lsusb工具是usbutils包的一部分,所以你需要按照如下命令安装:

#yum install usbutils
[root@devops tmp]# yum install usbutils
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package usbutils.x86_64 0:003-4.el6 will be installed
--> Processing Dependency: libusb-1.0.so.0()(64bit) for package: usbutils-003-4.el6.x86_64
--> Running transaction check
---> Package libusb1.x86_64 0:1.0.9-0.6.rc1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

============================================

============
 Package                     Arch                      Version                              

      Size
=======================================================
============
Installing:
 usbutils                    x86_64                    003-4.el6                                  

      71 k
Installing for dependencies:
 libusb1                     x86_64                    1.0.9-0.6.rc1.el6                      

      80 k

Transaction Summary
================================================================

============
Install       2 Package(s)

Total download size: 152 k
Installed size: 377 k
Is this ok [y/N]: y
Downloading Packages:
(1/2): libusb1-1.0.9-0.6.rc1.el6.x86_64.rpm                                                     

 00:00     
(2/2): usbutils-003-4.el6.x86_64.rpm                                               

 00:00     
--------------------------------------------------------

------------
Total                                                                                     

 00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : libusb1-1.0.9-0.6.rc1.el6.x86_64                                                                  

       1/2 
  Installing : usbutils-003-4.el6.x86_64                                                                         

       2/2 
  Verifying  : usbutils-003-4.el6.x86_64                                                                         

       1/2 
  Verifying  : libusb1-1.0.9-0.6.rc1.el6.x86_64                                                                  

       2/2 

Installed:
  usbutils.x86_64 0:003-4.el6                                                                                    

Dependency Installed:
  libusb1.x86_64 0:1.0.9-0.6.rc1.el6                                                                             

Complete!
AI 代码解读

示例:

[root@devops tmp]# lsusb
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 002: ID 0627:0001 Adomax Technology Co., Ltd 
[root@devops tmp]#
AI 代码解读

6. lsblk-列出块设备的信息

[root@devops tmp]# lsblk
NAME    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
xvda    202:0    0    20G  0 disk 
└─xvda1 202:1    0    20G  0 part /
xvdb    202:16   0    10G  0 disk 
└─xvdb1 202:17   0    10G  0 part /alidata
sr0      11:0    1   362K  0 rom
AI 代码解读

7. lsscsi-列出SCSI的设备信息

列出SCSI/SDAT设备的信息,比如硬盘驱动器、光盘驱动器。

[root@devops tmp]# lsscsi
[1:0:0:0]    cd/dvd  QEMU     QEMU DVD-ROM     0.10  /dev/sr0 
[root@devops tmp]#
AI 代码解读

完毕!Enjoy this!

目录
打赏
0
0
0
0
14291
分享
相关文章
|
27天前
|
linux命令详细说明以及案例
本文介绍了常用的 Linux 命令及其详细说明和示例,包括:`ls`(列出目录内容)、`cd`(更改目录)、`rm` 和 `mv`(删除与移动文件)、`grep`(搜索文本)、`cat`(显示文件内容)以及 `chmod`(更改文件权限)。每个命令均配有功能描述、选项说明及实际案例,帮助用户更好地掌握 Linux 命令的使用方法。
142 56
Linux系统中的cd命令:目录切换技巧
踏过千山,越过万水,人生就是一场不断前行的旅程,总充满了未知与挑战。然而,“cd”命令如同你的旅伴,会带你穿梭在如棋盘一般的文件系统中,探索每一处未知。希望你能从“cd”命令中找到乐趣,像是掌控了一种络新妙的魔法,去向未知进发,开始你的探索之旅。
86 24
|
4天前
|
Linux命令的基本格式解析
总的来说,Linux命令的基本格式就像一个食谱,它可以指导你如何使用你的计算机。通过学习和实践,你可以成为一个真正的“计算机厨师”,创造出各种“美味”的命令。
41 15
Linux系统之su命令的基本使用
Linux系统之su命令的基本使用
64 2
Linux系统之su命令的基本使用
调试技巧 - 用Linux命令排查Java问题
总的来说,使用Linux命令来排查Java问题,需要一定的实践经验和理论知识。然而,只要我们愿意花时间深入了解这些工具,我们就能够熟练地使用它们来分析和解决问题。此外,这些工具只是帮助我们定位问题,真正解决问题需要我们对Java和JVM有深入的理解,并能够读懂和分析代码。
57 13
|
29天前
|
Linux基础:文件和目录类命令分析。
总的来说,这些基础命令,像是Linux中藏匿的小矮人,每一次我们使用他们,他们就把我们的指令准确的传递给Linux,让我们的指令变为现实。所以,现在就开始你的Linux之旅,挥动你的命令之剑,探索这个充满神秘而又奇妙的世界吧!
71 19
|
1月前
|
Linux 常用文件查看命令
`cat` 命令用于连接文件并打印到标准输出,适用于快速查看和合并文本文件内容。常用示例包括:`cat file1.txt` 查看单个文件,`cat file1.txt file2.txt` 合并多个文件,`cat > filename` 创建新文件,`cat >> filename` 追加内容。`more` 和 `less` 命令用于分页查看文件,`tail` 命令则用于查看文件末尾内容,支持实时追踪日志更新,如 `tail -f file.log`。
66 5
Linux 常用文件查看命令
|
27天前
|
linux常用命令详细说明以及案例
本文介绍了Linux中几个常用的命令及其用法,包括:`ls`(列出目录内容)、`cd`(切换目录)、`mkdir`(创建目录)、`rm -p`(删除目录及内容)和`mv`(移动或重命名文件/目录)。每个命令都配有详细说明、语法格式、常见选项及实用案例,帮助用户更好地理解和使用这些基础命令。内容源自[linux常用命令详细说明以及案例](https://linux.ciilii.com/show/news-285.html)。
|
1月前
|
Linux od命令
本文详细介绍了Linux中的 `od`命令,包括其基本语法、常用选项和示例。通过这些内容,你可以灵活地使用 `od`命令查看文件内容,提高分析和调试效率。确保理解每一个选项和示例的实现细节,应用到实际工作中时能有效地处理各种文件查看需求。
73 19
|
2月前
|
Linux查看内存命令
1. free free命令是最常用的查看内存使用情况的命令。它显示系统的总内存、已使用内存、空闲内存和交换内存的总量。 free -h • -h 选项:以易读的格式(如GB、MB)显示内存大小。 输出示例: total used free shared buff/cache available Mem: 15Gi 4.7Gi 4.1Gi 288Mi 6.6Gi 9.9Gi Swap: 2.0Gi 0B 2.0Gi • to
98 2
下一篇
oss创建bucket
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等