了解正在运行的Linux系统的硬件是一个非常好的习惯,可以更好的完成后续系统上安装软件包、驱动程序兼容等方面问题。下面是一些常用Linux中提取有关系统和硬件组件信息的命令。
查看Linux系统信息:
tecmint@tecmint ~ $ uname
Linux
查看Linux网络主机名:
tecmint@tecmint ~ $ uname -n
tecmint.com
获取Linux内核相关信息:
tecmint@tecmint ~ $ uname -v
获取Linux内核版本相关信息:
howtoing@howtoing〜$ uname -r
打印Linux硬件架构名称:
howtoing@howtoing〜$ uname -m
一次性打印以上全部信息:
tecmint@tecmint ~ $ uname -a
查看Linux系统硬件信息,如CPU、磁盘、内存、USB控制器等,lshw是一个相对较小工具,提供的信息是从不同的/proc 文件中收集的。lshw命令由超级用户( root)或sudo用户执行。
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
int13floppytoshiba int13floppy360 int13floppy1200 int13floppy720
int13floppy2880 int9keyboard int10video acpi usb biosbootspecification uefi
......
使用-short该选项打印硬件信息摘要。
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 文件形式的输出,则可以使用选项-html。
tecmint@tecmint〜$ sudo lshw -html > lshw.html
查看LinuxCPU信息可以使用Iscpu命令来显示关于CPU架构信息,如来自sysfs和/proc/cpuinfo的 CPU 数量、核心、CPU 系列型号、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
lsblk命令用于报告有关块设备的信息,如下所示。
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
查看系统上的所有块设备。
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
lsusb命令用于报告有关 USB 控制器及其连接的所有设备的信息。
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