10 個(gè)用于收集硬件信息的 Linux 命令

2021-02-16    分類: 網(wǎng)站建設(shè)

1.如何查看Linux系統(tǒng)的信息

如果只想知道系統(tǒng)名稱,可以使用不帶任何參數(shù)選項(xiàng)的uname命令,就可以輸出系統(tǒng)信息,或使用uname -s命令輸出系統(tǒng)的內(nèi)核名稱。

tecmint@tecmint ~ $ uname
Linux

要查看網(wǎng)絡(luò)主機(jī)名,用“-n”參數(shù)選項(xiàng)的uname命令,如下所示。

tecmint@tecmint ~ $ uname -n
tecmint.com

要獲取有關(guān)內(nèi)核版本的信息,使用“-v”參數(shù)選項(xiàng)。

tecmint@tecmint ~ $ uname -v
#64-Ubuntu SMP Mon Sep 22 21:28:38 UTC 2014

要得到有關(guān)你的內(nèi)核的發(fā)行版信息,請(qǐng)使用“-r”參數(shù)選項(xiàng)。

tecmint@tecmint ~ $ uname -r
3.13.0-37-generic

要輸出你的機(jī)器的硬件名,使用“-m”參數(shù)選項(xiàng):

tecmint@tecmint ~ $ uname -m
x86_64

所有這些信息可以通過運(yùn)行“uname -a”命令,如下圖所示一次性輸出。

tecmint@tecmint ~ $ uname -a
Linux tecmint.com 3.13.0-37-generic #64-Ubuntu SMP Mon Sep 22 21:28:38 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

2.如何查看Linux的系統(tǒng)硬件信息

你可以使用lshw工具來收集有關(guān)硬件部件,如CPU,硬盤,內(nèi)存,USB控制器等的大量信息。

lshw是一個(gè)相對(duì)比較小巧的工具,當(dāng)你提取信息的時(shí)候,只有為數(shù)不多的幾個(gè)選項(xiàng)可供你使用。由lshw提供的信息收集形成了不同的/ proc文件。

注:請(qǐng)記住,lshw命令是由superuser (root)或sudo用戶執(zhí)行的。

參見:《Difference Between su and sudo User in Linux》

要輸出你的Linux系統(tǒng)的硬件信息,運(yùn)行此命令。

tecmint@tecmint ~ $ sudo lshw
tecmint.com 
 description: Notebook
 product: 20354 (LENOVO_MT_20354_BU_idea_FM_Lenovo Z50-70)
 vendor: LENOVO
 version: Lenovo Z50-70
 serial: 1037407803441
 width: 64 bits
 capabilities: smbios-2.7 dmi-2.7 vsyscall32
 configuration: administrator_password=disabled boot=normal chassis=notebook family=IDEAPAD frontpanel_password=disabled keyboard_password=disabled power-on_password=disabled sku=LENOVO_MT_20354_BU_idea_FM_Lenovo Z50-70 uuid=E4B1D229-D237-E411-9F6E-28D244EBBD98
 *-core
 description: Motherboard
 product: Lancer 5A5
 vendor: LENOVO
 physical id: 0
 version: 31900059WIN
 serial: YB06377069
 slot: Type2 - Board Chassis Location
 *-firmware
 description: BIOS
 vendor: LENOVO
 physical id: 0
 version: 9BCN26WW
 date: 07/31/2014
 size: 128KiB
 capacity: 4032KiB
 capabilities: pci upgrade shadowing cdboot bootselect edd int13floppynec int13floppytoshiba int13floppy360 int13floppy1200 int13floppy720 int13floppy2880 int9keyboard int10video acpi usb biosbootspecification uefi
......

你可以通過使用-short選項(xiàng)來輸出匯總的硬件信息。

tecmint@tecmint ~ $ sudo lshw -short
H/W path Device Class Description
=====================================================
 system 20354 (LENOVO_MT_20354_BU_idea_FM_Lenovo Z50-70)
/0 bus Lancer 5A5
/0/0 memory 128KiB BIOS
/0/4 processor Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz
/0/4/b memory 32KiB L1 cache
/0/4/c memory 256KiB L2 cache
/0/4/d memory 3MiB L3 cache
/0/a memory 32KiB L1 cache
/0/12 memory 8GiB System Memory
/0/12/0 memory DIMM [empty]
/0/12/1 memory DIMM [empty]
/0/12/2 memory 8GiB SODIMM DDR3 Synchronous 1600 MHz (0.6 ns)
/0/12/3 memory DIMM [empty]
/0/100 bridge Haswell-ULT DRAM Controller
/0/100/2 display Haswell-ULT Integrated Graphics Controller
/0/100/3 multimedia Haswell-ULT HD Audio Controller
...

如果你想生成輸出為HTML文件,可以使用選項(xiàng)-html。

tecmint@tecmint ~ $ sudo lshw -html > lshw.html

3.如何查看Linux的CPU信息

要查看關(guān)于CPU的信息,就使用lscpu命令,因?yàn)樗軓膕ysfs和/ proc / cpuinfo中顯示CPU體系結(jié)構(gòu)的信息,例如CPU數(shù)字,核心,CPU系列型號(hào),CPU高速緩存,線程等。

tecmint@tecmint ~ $ lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 4
On-line CPU(s) list: 0-3
Thread(s) per core: 2
Core(s) per socket: 2
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 69
Stepping: 1
CPU MHz: 768.000
BogoMIPS: 4788.72
Virtualization: VT-x
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 3072K
NUMA node0 CPU(s): 0-3

4.如何收集Linux塊設(shè)備信息

塊設(shè)備是諸如硬盤,閃存驅(qū)動(dòng)器等的存儲(chǔ)設(shè)備。lsblk命令可用于報(bào)告有關(guān)塊設(shè)備的信息,如下所示。

tecmint@tecmint ~ $ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 931.5G 0 disk 
├─sda1 8:1 0 1000M 0 part 
├─sda2 8:2 0 260M 0 part /boot/efi
├─sda3 8:3 0 1000M 0 part 
├─sda4 8:4 0 128M 0 part 
├─sda5 8:5 0 557.1G 0 part 
├─sda6 8:6 0 25G 0 part 
├─sda7 8:7 0 14.7G 0 part 
├─sda8 8:8 0 1M 0 part 
├─sda9 8:9 0 324.5G 0 part /
└─sda10 8:10 0 7.9G 0 part [SWAP]
sr0 11:0 1 1024M 0 rom

如果你想查看系統(tǒng)上所有的塊設(shè)備,那么就加一個(gè)-a選項(xiàng)。

tecmint@tecmint ~ $ lsblk -a
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 931.5G 0 disk 
├─sda1 8:1 0 1000M 0 part 
├─sda2 8:2 0 260M 0 part /boot/efi
├─sda3 8:3 0 1000M 0 part 
├─sda4 8:4 0 128M 0 part 
├─sda5 8:5 0 557.1G 0 part 
├─sda6 8:6 0 25G 0 part 
├─sda7 8:7 0 14.7G 0 part 
├─sda8 8:8 0 1M 0 part 
├─sda9 8:9 0 324.5G 0 part /
└─sda10 8:10 0 7.9G 0 part [SWAP]
sdb 8:16 1 0 disk 
sr0 11:0 1 1024M 0 rom 
ram0 1:0 0 64M 0 disk 
ram1 1:1 0 64M 0 disk 
ram2 1:2 0 64M 0 disk 
ram3 1:3 0 64M 0 disk 
ram4 1:4 0 64M 0 disk 
ram5 1:5 0 64M 0 disk 
ram6 1:6 0 64M 0 disk 
ram7 1:7 0 64M 0 disk 
ram8 1:8 0 64M 0 disk 
ram9 1:9 0 64M 0 disk 
loop0 7:0 0 0 loop 
loop1 7:1 0 0 loop 
loop2 7:2 0 0 loop 
loop3 7:3 0 0 loop 
loop4 7:4 0 0 loop 
loop5 7:5 0 0 loop 
loop6 7:6 0 0 loop 
loop7 7:7 0 0 loop 
ram10 1:10 0 64M 0 disk 
ram11 1:11 0 64M 0 disk 
ram12 1:12 0 64M 0 disk 
ram13 1:13 0 64M 0 disk 
ram14 1:14 0 64M 0 disk 
ram15 1:15 0 64M 0 disk

5.如何輸出USB控制器的信息

lsusb命令可用于報(bào)告關(guān)于USB控制器和所有連接到它們的設(shè)備的信息。

tecmint@tecmint ~ $ lsusb
Bus 001 Device 002: ID 8087:8000 Intel Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 005: ID 0bda:b728 Realtek Semiconductor Corp. 
Bus 002 Device 004: ID 5986:0249 Acer, Inc 
Bus 002 Device 003: ID 0bda:0129 Realtek Semiconductor Corp. RTS5129 Card Reader Controller
Bus 002 Device 002: ID 045e:00cb Microsoft Corp. Basic Optical Mouse v2.0
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

你可以使用-v選項(xiàng)生成有關(guān)于每個(gè)USB設(shè)備的詳細(xì)信息。

tecmint@tecmint ~ $ lsusb -v

6.如何輸出PCI設(shè)備信息

PCI設(shè)備可能包括USB接口,顯卡,網(wǎng)卡等。lspci工具能用來生成系統(tǒng)上所有PCI控制器以及連接到它們的設(shè)備的信息。

要輸出有關(guān)PCI設(shè)備的信息,可運(yùn)行以下命令。

tecmint@tecmint ~ $ lspci
00:00.0 Host bridge: Intel Corporation Haswell-ULT DRAM Controller (rev 0b)
00:02.0 VGA compatible controller: Intel Corporation Haswell-ULT Integrated Graphics Controller (rev 0b)
00:03.0 Audio device: Intel Corporation Haswell-ULT HD Audio Controller (rev 0b)
00:14.0 USB controller: Intel Corporation Lynx Point-LP USB xHCI HC (rev 04)
00:16.0 Communication controller: Intel Corporation Lynx Point-LP HECI #0 (rev 04)
00:1b.0 Audio device: Intel Corporation Lynx Point-LP HD Audio Controller (rev 04)
00:1c.0 PCI bridge: Intel Corporation Lynx Point-LP PCI Express Root Port 3 (rev e4)
00:1c.3 PCI bridge: Intel Corporation Lynx Point-LP PCI Express Root Port 4 (rev e4)
00:1c.4 PCI bridge: Intel Corporation Lynx Point-LP PCI Express Root Port 5 (rev e4)
00:1d.0 USB controller: Intel Corporation Lynx Point-LP USB EHCI #1 (rev 04)
00:1f.0 ISA bridge: Intel Corporation Lynx Point-LP LPC Controller (rev 04)
00:1f.2 SATA controller: Intel Corporation Lynx Point-LP SATA Controller 1 [AHCI mode] (rev 04)
00:1f.3 SMBus: Intel Corporation Lynx Point-LP SMBus Controller (rev 04)
01:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 10)
02:00.0 Network controller: Realtek Semiconductor Co., Ltd. RTL8723BE PCIe Wireless Network Adapter
03:00.0 3D controller: NVIDIA Corporation GM108M [GeForce 840M] (rev a2)

使用-t選項(xiàng)將以樹的形式生成輸出。

tecmint@tecmint ~ $ lspci -t
-[0000:00]-+-00.0
 +-02.0
 +-03.0
 +-14.0
 +-16.0
 +-1b.0
 +-1c.0-[01]----00.0
 +-1c.3-[02]----00.0
 +-1c.4-[03]----00.0
 +-1d.0
 +-1f.0
 +-1f.2
 \-1f.3

使用-v選項(xiàng)生成有關(guān)每個(gè)連接的設(shè)備的詳細(xì)信息。

tecmint@tecmint ~ $ lspci -v
00:00.0 Host bridge: Intel Corporation Haswell-ULT DRAM Controller (rev 0b)Subsystem: Lenovo Device 3978Flags: bus master, fast devsel, latency 0Capabilities: 
00:02.0 VGA compatible controller: Intel Corporation Haswell-ULT Integrated Graphics Controller (rev 0b) (prog-if 00 [VGA controller])Subsystem: Lenovo Device 380dFlags: bus master, fast devsel, latency 0, IRQ 62Memory at c3000000 (64-bit, non-prefetchable) [size=4M]Memory at d0000000 (64-bit, prefetchable) [size=256M]I/O ports at 6000 [size=64]Expansion ROM at [disabled]Capabilities: Kernel driver in use: i915
.....

7.如何輸出SCSI設(shè)備的信息

要查看所有的scsi / sata設(shè)備,可使用lsscsi命令,如下所示。如果你沒有安裝lsscsi工具,那么運(yùn)行下面的命令來安裝它。

$ sudo apt-get install lsscsi [on Debian derivatives]
# yum install lsscsi [On RedHat based systems]
# dnf install lsscsi [On Fedora 21+ Onwards]

安裝后,運(yùn)行l(wèi)sscsi命令,如下所示:

tecmint@tecmint ~ $ lsscsi
[0:0:0:0] disk ATA ST1000LM024 HN-M 2BA3 /dev/sda 
[1:0:0:0] cd/dvd PLDS DVD-RW DA8A5SH RL61 /dev/sr0 
[4:0:0:0] disk Generic- xD/SD/M.S. 1.00 /dev/sdb

使用-s選項(xiàng)來顯示設(shè)備尺寸。

tecmint@tecmint ~ $ lsscsi -s
[0:0:0:0] disk ATA ST1000LM024 HN-M 2BA3 /dev/sda 1.00TB
[1:0:0:0] cd/dvd PLDS DVD-RW DA8A5SH RL61 /dev/sr0 -
[4:0:0:0] disk Generic- xD/SD/M.S. 1.00 /dev/sdb -

8.如何打印有關(guān)SATA設(shè)備的信息

你可以使用hdparm實(shí)用工具在系統(tǒng)上找到有關(guān)sata設(shè)備的一些信息,如下所示。在下面的例子中,我使用了塊設(shè)備/ dev / sda1。

tecmint@tecmint ~ $ sudo hdparm /dev/sda1
/dev/sda1:
 multcount = 0 (off)
 IO_support = 1 (32-bit)
 readonly = 0 (off)
 readahead = 256 (on)
 geometry = 56065/255/63, sectors = 2048000, start = 2048

要輸出設(shè)備有關(guān)柱面、磁頭、扇區(qū)、大小和起始偏移量的幾何信息,使用-g選項(xiàng)。

tecmint@tecmint ~ $ sudo hdparm -g /dev/sda1
/dev/sda1:
 geometry = 56065/255/63, sectors = 2048000, start = 2048

9.如何輸出Linux文件系統(tǒng)信息

為了收集有關(guān)文件系統(tǒng)分區(qū)的信息,你可以使用fdisk命令。雖然fdisk命令的主要功能是修改文件系統(tǒng)分區(qū),但我們也可以用它來查看文件系統(tǒng)上不同分區(qū)的信息。

你可以按如下方法輸出分區(qū)信息。記住要用超級(jí)用戶的身份運(yùn)行命令,否則你可能看不到任何輸出。

tecmint@tecmint ~ $ sudo fdisk -l
WARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util fdisk doesn't support GPT. Use GNU Parted.
Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0xcee8ad92
 Device Boot Start End Blocks Id System
/dev/sda1 1 1953525167 976762583+ ee GPT
Partition 1 does not start on physical sector boundary.

10.如何提取有關(guān)硬件組件的信息

你也可以使用dmidecode實(shí)用程序通過讀取DMI表中的數(shù)據(jù)提取硬件信息。

輸出有關(guān)內(nèi)存的信息,作為超級(jí)用戶運(yùn)行此命令。

tecmint@tecmint ~ $ sudo dmidecode -t memory
# dmidecode 2.12
# SMBIOS entry point at 0xaaebef98
SMBIOS 2.7 present.
Handle 0x0005, DMI type 5, 24 bytes
Memory Controller InformationError Detecting Method: NoneError Correcting Capabilities:	NoneSupported Interleave: One-way InterleaveCurrent Interleave: One-way InterleaveMaximum Memory Module Size: 8192 MBMaximum Total Memory Size: 32768 MBSupported Speeds:	OtherSupported Memory Types:	OtherMemory Module Voltage: UnknownAssociated Memory Slots: 4	0x0006	0x0007	0x0008	0x0009Enabled Error Correcting Capabilities:	None
...

要輸出有關(guān)系統(tǒng)的信息,運(yùn)行此命令。

tecmint@tecmint ~ $ sudo dmidecode -t system
# dmidecode 2.12
# SMBIOS entry point at 0xaaebef98
SMBIOS 2.7 present.
Handle 0x0001, DMI type 1, 27 bytes
System InformationManufacturer: LENOVOProduct Name: 20354Version: Lenovo Z50-70Serial Number: 1037407803441UUID: 29D2B1E4-37D2-11E4-9F6E-28D244EBBD98Wake-up Type: Power SwitchSKU Number: LENOVO_MT_20354_BU_idea_FM_Lenovo Z50-70Family: IDEAPAD
...

要輸出有關(guān)BIOS的信息,運(yùn)行此命令。

tecmint@tecmint ~ $ sudo dmidecode -t bios
# dmidecode 2.12
# SMBIOS entry point at 0xaaebef98
SMBIOS 2.7 present.
Handle 0x0000, DMI type 0, 24 bytes
BIOS InformationVendor: LENOVOVersion: 9BCN26WWRelease Date: 07/31/2014Address: 0xE0000Runtime Size: 128 kBROM Size: 4096 kBCharacteristics:	PCI is supported	BIOS is upgradeable	BIOS shadowing is allowed	Boot from CD is supported	Selectable boot is supported	EDD is supported	Japanese floppy for NEC 9800 1.2 MB is supported (int 13h)	Japanese floppy for Toshiba 1.2 MB is supported (int 13h)	5.25"/360 kB floppy services are supported (int 13h)	5.25"/1.2 MB floppy services are supported (int 13h)	3.5"/720 kB floppy services are supported (int 13h)	3.5"/2.88 MB floppy services are supported (int 13h)	8042 keyboard services are supported (int 9h)	CGA/mono video services are supported (int 10h)	ACPI is supported	USB legacy is supported	BIOS boot specification is supported	Targeted content distribution is supported	UEFI is supportedBIOS Revision: 0.26Firmware Revision: 0.26
...

要輸出關(guān)于處理器的信息,運(yùn)行此命令。

tecmint@tecmint ~ $ sudo dmidecode -t processor
# dmidecode 2.12
# SMBIOS entry point at 0xaaebef98
SMBIOS 2.7 present.
Handle 0x0004, DMI type 4, 42 bytes
Processor InformationSocket Designation: U3E1Type: Central ProcessorFamily: Core i5Manufacturer: Intel(R) CorporationID: 51 06 04 00 FF FB EB BFSignature: Type 0, Family 6, Model 69, Stepping 1Flags:

當(dāng)前名稱:10 個(gè)用于收集硬件信息的 Linux 命令
當(dāng)前URL:http://muchs.cn/news46/101296.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站制作、企業(yè)網(wǎng)站制作、網(wǎng)站設(shè)計(jì)標(biāo)簽優(yōu)化、小程序開發(fā)、移動(dòng)網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

商城網(wǎng)站建設(shè)