使用lshw命令可以查看服务器硬件配置的详细信息。使用它可以在支持DMI的x86或IA-64系统以及某些PowerPC机器上打印内存配置、固件版本、主板配置、CPU版本、G4可以工作)。目前该命令支持 CPU频率、缓存、总线速度等信息(已知PowerMac DMI(仅限x86和IA-64)、OpenFimware设备树(仅限PowerPC)、PCI/AGP、CPUID(x86)、IDE/ATA/ATAPI、PCMCIA(仅在x86上测试)、SCSI和USB等信息的查看。
使用方法:
lshw [ -version ]
先使用lsblk命令查看磁盘的设备名称和容量的对应关系:
root@VM-4-5-ubuntu:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 17M 0 rom
vda 252:0 0 40G 0 disk
└─vda1 252:1 0 40G 0 part /
再使用ip addr命令查看网卡接口名称和IP地址的对应关系:
root@VM-4-5-ubuntu:~# ip addr
1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00inet 127.0.0.1/8 scope host lovalid_lft forever preferred_lft foreverinet6 ::1/128 scope host valid_lft forever preferred_lft forever
2: eth0: mtu 1500 qdisc mq state UP group default qlen 1000link/ether 52:54:00:56:11:4f brd ff:ff:ff:ff:ff:ffinet 10.0.4.5/22 brd 10.0.7.255 scope global eth0valid_lft forever preferred_lft foreverinet6 fe80::5054:ff:fe56:114f/64 scope link valid_lft forever preferred_lft forever
接下来使用lshw命令可以一次性查看大部分设备的型号信息(也可以不使用简短格式,但是详尽格式内容过长,文本格式不便阅读):
root@VM-4-5-ubuntu:~# lshw -short
H/W path Device Class Description
================================================system CVM
/0 bus Motherboard #主板型号
/0/0 memory 96KiB BIOS
/0/400 processor Intel(R) Xeon(R) Gold 6133 CPU @ 2.50GHz #CPU型号
/0/1000 memory 2GiB System Memory #使用简短格式无法看到内存型号
/0/1000/0 memory 2GiB DIMM RAM
/0/100 bridge 440FX - 82441FX PMC [Natoma]
/0/100/1 bridge 82371SB PIIX3 ISA [Natoma/Triton II]
/0/100/1.1 storage 82371SB PIIX3 IDE [Natoma/Triton II]
/0/100/1.2 bus 82371SB PIIX3 USB [Natoma/Triton II]
/0/100/1.2/1 usb1 bus UHCI Host Controller
/0/100/1.3 bridge 82371AB/EB/MB PIIX4 ACPI
/0/100/2 display GD 5446
/0/100/3 bridge QEMU PCI-PCI bridge
/0/100/4 bridge QEMU PCI-PCI bridge
/0/100/5 network Virtio network device
/0/100/5/0 eth0 network Ethernet interface
/0/100/6 storage Virtio block device
/0/100/6/0 /dev/vda disk 42GB Virtual I/O device
/0/100/6/0/1 /dev/vda1 volume 39GiB EXT4 volume
/0/100/7 generic Virtio memory balloon
/0/100/7/0 generic Virtual I/O device
/0/1 scsi0 storage
/0/1/0.1.0 /dev/cdrom disk QEMU DVD-ROM
/0/1/0.1.0/0 /dev/cdrom disk
由于使用简短格式无法查看到内存型号信息,所以下面使用了详尽格式,并使用- class选项指定简短格式的class输出列为memory字符串。
root@tbs-36:~# lshw -class memory*-firmware description: BIOSvendor: American Megatrends Inc.physical id: 0version: 5.12date: 03/28/2018size: 64KiBcapacity: 15MiBcapabilities: pci upgrade shadowing cdboot bootselect socketedrom edd int13floppy1200 int13floppy720 int13floppy2880 int5printscreen int14serial int17printer acpi usb biosbootspecification uefi*-memorydescription: System Memoryphysical id: 3dslot: System board or motherboardsize: 16GiB*-bank:0description: SODIMM Synchronous 2400 MHz (0.4 ns)product: CBD24D4S7S8ME-8vendor: Kingstonphysical id: 0serial: C18C8ADEslot: ChannelA-DIMM0size: 8GiBwidth: 64 bitsclock: 2400MHz (0.4ns)*-bank:1description: Project-Id-Version: lshwReport-Msgid-Bugs-To: FULL NAME POT-Creation-Date: 2009-10-08 14:02+0200PO-Revision-Date: 2012-10-07 14:34+0000Last-Translator: lumingzh Language-Team: Chinese (Simplified) MIME-Version: 1.0Content-Type: text/plain; charset=UTF-8Content-Transfer-Encoding: 8bitX-Launchpad-Export-Date: 2016-07-20 12:06+0000X-Generator: Launchpad (build 18147)Project-Id-Version: lshwReport-Msgid-Bugs-To: FULL NAME POT-Creation-Date: 2009-10-08 14:02+0200PO-Revision-Date: 2012-10-07 14:34+0000Last-Translator: lumingzh Language-Team: Chinese (Simplified) MIME-Version: 1.0Content-Type: text/plain; charset=UTF-8Content-Transfer-Encoding: 8bitX-Launchpad-Export-Date: 2016-07-20 12:06+0000X-Generator: Launchpad (build 18147) [empty]physical id: 1slot: ChannelA-DIMM1*-bank:2description: SODIMM Synchronous 2400 MHz (0.4 ns)product: CBD24D4S7S8ME-8 #内存型号vendor: Kingstonphysical id: 2serial: C58C90CEslot: ChannelB-DIMM0size: 8GiBwidth: 64 bitsclock: 2400MHz (0.4ns)*-bank:3description: Project-Id-Version: lshwReport-Msgid-Bugs-To: FULL NAME POT-Creation-Date: 2009-10-08 14:02+0200PO-Revision-Date: 2012-10-07 14:34+0000Last-Translator: lumingzh Language-Team: Chinese (Simplified) MIME-Version: 1.0Content-Type: text/plain; charset=UTF-8Content-Transfer-Encoding: 8bitX-Launchpad-Export-Date: 2016-07-20 12:06+0000X-Generator: Launchpad (build 18147)Project-Id-Version: lshwReport-Msgid-Bugs-To: FULL NAME POT-Creation-Date: 2009-10-08 14:02+0200PO-Revision-Date: 2012-10-07 14:34+0000Last-Translator: lumingzh Language-Team: Chinese (Simplified) MIME-Version: 1.0Content-Type: text/plain; charset=UTF-8Content-Transfer-Encoding: 8bitX-Launchpad-Export-Date: 2016-07-20 12:06+0000X-Generator: Launchpad (build 18147) [empty]physical id: 3slot: ChannelB-DIMM1*-cache:0description: L1 cachephysical id: 43slot: L1 Cachesize: 128KiBcapacity: 128KiBcapabilities: synchronous internal write-back unified*-cache:1description: L2 cachephysical id: 44slot: L2 Cachesize: 512KiBcapacity: 512KiBcapabilities: synchronous internal write-back unified*-cache:2description: L3 cachephysical id: 45slot: L3 Cachesize: 3MiBcapacity: 3MiBcapabilities: synchronous internal write-back unified*-memory UNCLAIMEDdescription: Memory controllerproduct: Intel Corporation #内存型号vendor: Intel Corporationphysical id: 1f.2bus info: pci@0000:00:1f.2version: 21width: 32 bitsclock: 33MHz (30.3ns)capabilities: bus_masterconfiguration: latency=0resources: memory:df324000-df327fff
使用lshw命令还可以生成一个详尽的HTML格式文件,使用浏览器打开之后更容易查 看到设备型号信息(也更容易看出哪些网卡接口、磁盘分区是属于同一个设备的)。
root@tbs-36# lshw -html > hardware.html
使用浏览器打开这个HTML文件,我们可以更容易地找到设备型号信息。
查看主板型号,如图40-1所示。

查看CPU型号,如图40-2所示。

查看内存型号,如图40-3所示。

查看阵列卡型号,如图40-4所示。

查看网卡型号,如图40-7所示。

查看显卡型号,如图40-8所示。

使用dmidecode命令可以读取/dev/mem二进制文件并进行解析,然后以人类可读的格式转储计算机的DMI(或者SMBIOS)表内容,该表中包含了系统硬件组件的描述,以及其他有用的信息(例如:BIOS序列号和版本信息)。借助此表的信息,虽然可以不需要实际去机房查看硬件的型号,但是这也使得查询的信息可能不可靠。 SMBIOS代表系统管理BIOS,而DMI代表桌面管理界面。这两个标准都与DMTF(桌面管理任务组)的开发紧密相关。 使用方法
dmidecode [OPTIONS]
DMI类型编号列表:

DMI 类型编号与DMI 类型关键字的对应关系:


使用dmidecode命令查看CPU型号信息:

使用dmidecode命令查看内存型号信息:

使用dmidecode命令查看网卡型号(板载设备)信息:

提示:dmidecode命令可能不支持查看PCI设备信息(即无法查看外部设备信息),笔者在实践中并没有找 到PCIe Flash SSD设备的型号信息。
dmesg命令用于打印或控制内核环形缓冲区(Kernel Ring Buffer)的内容。 使用方法:
dmesg[options]
-c:打印内核环形缓冲区中的内容之后清除缓冲区。
-r:打印原始内核环形缓冲区的内容,即保留每行日志信息的日志级别前缀。
-s, --buffer-size :使用指定大小的缓冲区来查询内核环形缓冲区。默认值为16392 字节(默认内核syslog缓冲区大小最初为4096字节,从2.1.54版本开始修改为8192字节, 从2.1.113版本开始修改为16384字节)。如果将内核环形缓冲区的大小设置为大于默认 值,则表示可以查看整个内核环形缓冲区的内容(因为有足够的空间存放数据)。
-n level:设置将消息记录到控制台(Console)的级别。例如,-n 1可以防止除panic级别消息之外的其他级别消息打印到控制台,但所有级别消息仍然会被写 入/proc/kmsg文件中。
当使用-n选项时,dmesg不会打印也不会清除内核环形缓冲区的内容。
如果多次使用该选项,则只有最后一个选项会生效。
先使用lsblk命令查看磁盘设备名称和容量的对应关系:

从以上内容来看,无法找到内存和网卡设备的型号信息。
上一篇:国足犯罪式丢球!刘洋被骂踢假球,揪出三大罪人,新加坡美女看呆
下一篇:pca降维