Linux命令查找系统配置和硬件信息

时间:2020-01-09 10:41:21  来源:igfitidea点击:

使用命令行(文本)模式在Linux操作系统上查找系统配置的命令是什么?
在基于Linux的系统上,可以从/proc文件系统中提取大多数硬件信息,例如显示CPU和内存信息,执行:

cat/proc/meminfo cat/proc/cpuinfo

以下列表总结了从系统中获取各种硬件的命令:

Linux cpu /硬件信息

使用以下任一命令:

# less /proc/cpuinfo

或者

# lscpu

输出示例:

Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                32
On-line CPU(s) list:   0-31
Thread(s) per core:    2
Core(s) per socket:    8
Socket(s):             2
NUMA node(s):          2
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 45
Stepping:              7
CPU MHz:               1999.874
BogoMIPS:              4000.99
Virtualization:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              20480K
NUMA node0 CPU(s):     0-7,16-23
NUMA node1 CPU(s):     8-15,24-31

Linux显示系统中的可用内存和已用内存

使用以下任一命令:

# cat /proc/meminfo

或者

# free
# free -m
# free -mt
# free -gt

输出示例:

total       used       free     shared    buffers     cached
Mem:      32911564   32665848     245716     168592     294192   29324484
-/+ buffers/cache:    3047172   29864392
Swap:       999420      81832     917588

您还可以运行top/htop/atop命令来查看已用和可用内存以及cpu的使用情况以及更多信息:

# top
# htop
# atop

查找服务器的RAM速度和最大支持RAM

# dmidecode --type 17
# lshw -short -C memory
# perl memconf.v3.06.pl -v

输出示例:

memconf:  V3.06 17-Feb-2014 http://sourceforge.net/projects/memconf/
hostname: server1
manufacturer: Supermicro
model:    X9DRi-LN4+/X9DR3-LN4+ (2 X Eight-Core Hyper-Threaded Intel(R) Xeon(R) E5-2650 0 @ 2.00GHz)
BusyBox v1.21.1
is, Ubuntu 14.04.2 LTS, 64-bit kernel, Linux 3.13.0-46-generic
CPU 1: Intel(R) Xeon(R) E5-2650 0 @ 2.00GHz cpu, system freq: 100MHz
CPU 2: Intel(R) Xeon(R) E5-2650 0 @ 2.00GHz cpu, system freq: 100MHz
Memory Error Correction: Multi-bit ECC
Maximum Memory: 786432MB (768GB)
P1-DIMMA1 P0_Node0_Channel0_Dimm0: 4096MB 1600MHz Registered (Buffered) DDR3 DIMM, Kingston SL4D316R11D8HE
P1-DIMMB1 P0_Node0_Channel1_Dimm0: 4096MB 1600MHz Registered (Buffered) DDR3 DIMM, Kingston SL4D316R11D8HE
P1-DIMMC1 P0_Node0_Channel2_Dimm0: 4096MB 1600MHz Registered (Buffered) DDR3 DIMM, Kingston SL4D316R11D8HE
P1-DIMMD1 P0_Node0_Channel3_Dimm0: 4096MB 1600MHz Registered (Buffered) DDR3 DIMM, Kingston SL4D316R11D8HE
P2-DIMME1 P1_Node1_Channel0_Dimm0: 4096MB 1600MHz Registered (Buffered) DDR3 DIMM, Kingston SL4D316R11D8HE
P2-DIMMF1 P1_Node1_Channel1_Dimm0: 4096MB 1600MHz Registered (Buffered) DDR3 DIMM, Kingston SL4D316R11D8HE
P2-DIMMG1 P1_Node1_Channel2_Dimm0: 4096MB 1600MHz Registered (Buffered) DDR3 DIMM, Kingston SL4D316R11D8HE
P2-DIMMH1 P1_Node1_Channel3_Dimm0: 4096MB 1600MHz Registered (Buffered) DDR3 DIMM, Kingston SL4D316R11D8HE

Linux找出当前正在运行的内核版本

执行以下命令:

# cat /proc/version

输出示例:

Linux version 3.2.0-43-generic (buildd@batsu) (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) ) #68-Ubuntu SMP Wed May 15 03:33:33 UTC 2013

或使用以下命令:

# uname -mrs
# uname -a

查找有关Linux发行版和版本的信息

# lsb_release -a

输出示例:

No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 12.04.2 LTS
Release:	12.04
Codename:	precise

或使用以下命令:

$ cat /etc/*release*

输出示例:

Red Hat Enterprise Linux Server release 6.4 (Santiago)

列出所有PCI设备

# lspci

输出示例:

00:00.0 Host bridge: Intel Corporation Xeon E5/Core i7 DMI2 (rev 07)
00:01.0 PCI bridge: Intel Corporation Xeon E5/Core i7 IIO PCI Express Root Port 1a (rev 07)
00:01.1 PCI bridge: Intel Corporation Xeon E5/Core i7 IIO PCI Express Root Port 1b (rev 07)
00:02.0 PCI bridge: Intel Corporation Xeon E5/Core i7 IIO PCI Express Root Port 2a (rev 07)
00:03.0 PCI bridge: Intel Corporation Xeon E5/Core i7 IIO PCI Express Root Port 3a in PCI Express Mode (rev 07)
00:04.0 System peripheral: Intel Corporation Xeon E5/Core i7 DMA Channel 0 (rev 07)
00:04.1 System peripheral: Intel Corporation Xeon E5/Core i7 DMA Channel 1 (rev 07)
00:04.2 System peripheral: Intel Corporation Xeon E5/Core i7 DMA Channel 2 (rev 07)
00:04.3 System peripheral: Intel Corporation Xeon E5/Core i7 DMA Channel 3 (rev 07)
80:01.0 PCI bridge: Intel Corporation Xeon E5/Core i7 IIO PCI Express Root Port 1a (rev 07)
80:02.0 PCI bridge: Intel Corporation Xeon E5/Core i7 IIO PCI Express Root Port 2a (rev 07)
80:03.0 PCI bridge: Intel Corporation Xeon E5/Core i7 IIO PCI Express Root Port 3a in PCI Express Mode (rev 07)
80:04.0 System peripheral: Intel Corporation Xeon E5/Core i7 DMA Channel 0 (rev 07)
80:04.1 System peripheral: Intel Corporation Xeon E5/Core i7 DMA Channel 1 (rev 07)
80:04.2 System peripheral: Intel Corporation Xeon E5/Core i7 DMA Channel 2 (rev 07)

列出所有USB设备

# lsusb

输出示例:

Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0557:2221 ATEN International Co., Ltd Winbond Hermon
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

列出所有块设备(硬盘,cdrom等)

# lsblk

输出示例:

sda      8:0    1 372.3G  0 disk 
|-sda1   8:1    1   243M  0 part /boot
|-sda2   8:2    1     1K  0 part 
|-sda5   8:5    1   976M  0 part [SWAP]
`-sda6   8:6    1 371.1G  0 part /
sr0     11:0    1  1024M  0 rom  
loop0    7:0    0     4G  0 loop /jails/tmp

显示已安装的硬盘和大小

# fdisk -l | grep '^Disk /dev/'

输出示例:

Disk /dev/sda: 399.7 GB, 399717171200 bytes

显示有关硬件RAID的信息

查看有关Adaptec硬件RAID的信息:

# arcconf getconfig DEV
# /usr/StorMan/arcconf getconfig 1

查看有关3ware硬件RAID的信息:

# tw_cli /dev show
# tw_cli /c0 show

lshw

lshw是一个小型命令行工具,用于提取有关计算机硬件配置的详细信息。
它可以报告具有DMI功能的x86或IA-64系统以及某些PowerPC机器上的确切内存配置,固件版本,主板配置,CPU版本和速度,缓存配置,总线速度等(已知PowerMac G4可以工作):

# lshw | more
# lshw -html > output.htmlq
# lshw -short | less

输出示例:

H/W path          Device      Class          Description
========================================================
                              system         X9DRi-LN4+/X9DR3-LN4+ (To be filled by O.E.M.)
/0                            bus            X9DRi-LN4+/X9DR3-LN4+
/0/0                          memory         64KiB BIOS
/0/4                          processor      Intel(R) Xeon(R) CPU E5-2650 0 @ 2.00GHz
/0/4/5                        memory         512KiB L1 cache
/0/4/6                        memory         2MiB L2 cache
/0/4/7                        memory         20MiB L3 cache
/0/6                          processor      Intel(R) Xeon(R) CPU E5-2650 0 @ 2.00GHz
/0/6/9                        memory         512KiB L1 cache
/0/6/a                        memory         2MiB L2 cache
/0/6/b                        memory         20MiB L3 cache
/0/2f                         memory         System Memory
/0/2f/0                       memory         4GiB DIMM DDR3 1600 MHz (0.6 ns)
/0/2f/1                       memory         DIMM Synchronous [empty]
/0/2f/2                       memory         DIMM Synchronous [empty]
....
...
..
/0/1                          bridge         Xeon E5/Core i7 IIO PCI Express Root Port 1a
/0/1/0/1.0.0                  disk           SCSI Disk
/0/1/0/1.1.0                  disk           SCSI Disk
/0/1/0/1.2.0                  disk           SCSI Disk
/0/1/0/1.3.0                  disk           SCSI Disk
...
..
...
/0/68             scsi5       storage        
/0/68/0.0.0       /dev/cdrom  disk           DV-28S-W
/1                            power          PWS-605P-1H
/2                vethWKP76N  network        Ethernet interface
/3                veth1N2SWB  network        Ethernet interface
/4                veth8L2A3F  network        Ethernet interface
/5                bond0       network        Ethernet interface

转储所有硬件信息

执行以下命令以直接从系统BIOS查看主板,CPU,供应商,序列号,RAM,磁盘和其他信息:

# dmidecode | less

输出示例:

# dmidecode 2.12
SMBIOS 2.7 present.
155 structures occupying 7700 bytes.
Table at 0x000EC440.
 
Handle 0x0000, DMI type 0, 24 bytes
BIOS Information
        Vendor: American Megatrends Inc.
        Version: 3.0b
        Release Date: 05/27/2014
        Address: 0xF0000
        Runtime Size: 64 kB
        ROM Size: 12288 kB
        Characteristics:
                PCI is supported
                BIOS is upgradeable
                BIOS shadowing is allowed
                Boot from CD is supported
                Selectable boot is supported
                BIOS ROM is socketed
                EDD is supported
                Print screen service is supported (int 5h)
                8042 keyboard services are supported (int 9h)
                Serial services are supported (int 14h)
                Printer services are supported (int 17h)
                ACPI is supported
                USB legacy is supported
                BIOS boot specification is supported
                Function key-initiated network boot is supported
                Targeted content distribution is supported
                UEFI is supported
        BIOS Revision: 3.11
 
Handle 0x0001, DMI type 1, 27 bytes
System Information
        Manufacturer: Supermicro
        Product Name: X9DRi-LN4+/X9DR3-LN4+
        Version: 0123456789
        Serial Number: 0123456789
        UUID: 00000000-0000-0000-0000-0025902E1590
        Wake-up Type: Power Switch
        SKU Number: To be filled by O.E.M.
        Family: To be filled by O.E.M.
 
Handle 0x0002, DMI type 2, 15 bytes
Base Board Information
        Manufacturer: Supermicro
....
..
...
 
Handle 0x00AB, DMI type 13, 22 bytes
BIOS Language Information
        Language Description Format: Long
        Installable Languages: 1
                en|US|iso8859-1
        Currently Installed Language: en|US|iso8859-1
 
Handle 0x00AE, DMI type 127, 4 bytes
End Of Table