首页 > *nix技术, Shell命令, 系统管理 > Linux环境下查看硬件信息

Linux环境下查看硬件信息

2011年12月7日 发表评论 阅读评论 6,134 次浏览

由于相关工作的关系,在Linux环境下查看硬件信息是经常的事情,陆陆续续也有了一些经验,这里总结一些。
一般而言,在Linux下查看硬件信息的最基本方法就是利用/proc文件系统,这个动态文件系统里提供了很多相关的信息,比如:

[root@localhost ~]# cat /proc/cpuinfo 
processor	: 0
vendor_id	: GenuineIntel
cpu family	: 6
model		: 15
model name	: Genuine Intel(R) CPU           T1400  @ 1.73GHz
stepping	: 13
cpu MHz		: 1729.001
cache size	: 512 KB
fdiv_bug	: no
hlt_bug		: no
f00f_bug	: no
coma_bug	: no
fpu		: yes
fpu_exception	: yes
cpuid level	: 10
...

[root@localhost ~]# cat /proc/ioports 
0000-001f : dma1
0020-0021 : pic1
0040-0043 : timer0
0050-0053 : timer1
0060-0060 : keyboard
0064-0064 : keyboard
0070-0071 : rtc0
0080-008f : dma page reg
00a0-00a1 : pic2
00c0-00df : dma2
00f0-00ff : fpu
0170-0177 : 0000:00:07.1
  0170-0177 : ata_piix
01f0-01f7 : 0000:00:07.1
  01f0-01f7 : ata_piix
02f8-02ff : serial
0376-0376 : 0000:00:07.1
...

[root@localhost ~]# cat /proc/meminfo 
MemTotal:        1031320 kB
MemFree:           54164 kB
Buffers:           83676 kB
Cached:           659676 kB
SwapCached:            8 kB
Active:           396052 kB
Inactive:         463516 kB
Active(anon):      10644 kB
Inactive(anon):   110216 kB
Active(file):     385408 kB
Inactive(file):   353300 kB
Unevictable:           0 kB
Mlocked:               0 kB
HighTotal:        141256 kB
HighFree:           6132 kB
LowTotal:         890064 kB
LowFree:           48032 kB
SwapTotal:       2064376 kB
SwapFree:        2064368 kB
Dirty:                 0 kB
Writeback:             0 kB
...

[root@localhost ~]# cat /proc/bus/usb/devices 

T:  Bus=02 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=12  MxCh= 2
B:  Alloc=  0/900 us ( 0%), #Int=  0, #Iso=  0
D:  Ver= 1.10 Cls=09(hub  ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=1d6b ProdID=0001 Rev= 2.06
S:  Manufacturer=Linux 2.6.32-71.el6.i686 uhci_hcd
S:  Product=UHCI Host Controller
S:  SerialNumber=0000:02:00.0
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   2 Ivl=255ms
...

[root@localhost ~]# cat /proc/bus/pci/devices 
0000	80867190	0	               0	               0	               0	               0	               0	               0	               0	               0	               0	               0	               0	               0	               0	               0	agpgart-intel
0008	80867191	0	               0	               0	               0	               0	               0	               0	               0	               0	               0	               0	               0	               0	               0	               0	
0038	80867110	0	               0	               0	               0	               0	               0	               0	               0	               0	               0	               0	               0	               0	               0	               0	
0039	80867111	0	             1f0	             3f6	             170	             376	            10c1	               0	               0	               8	               0	               8	               0	              10	               0	               0	ata_piix
003b	80867113	9	               0	               0	               0	               0	               0	               0	               0	               0	               0	               0	               0	               0	               0	               0	
003f	15ad0740	9	            1081	               0	               0	               0	               0	               0	               0	              40	               0	               0	               0	               0	               0...

[root@localhost ~]# cat /proc/bus/input/devices 
I: Bus=0019 Vendor=0000 Product=0001 Version=0000
N: Name="Power Button"
P: Phys=LNXPWRBN/button/input0
S: Sysfs=/devices/LNXSYSTM:00/LNXPWRBN:00/input/input0
U: Uniq=
H: Handlers=kbd event0 
B: EV=3
B: KEY=100000 0 0 0
...

/proc文件系统提供了很多用户接口,但是可读性不太好,所以也就有了一些更好的工具,比如:lscpu、dmidecode、lspci、smartctl、lsusb,这些命令工具的简单使用看man手册即可。当然,也还有很多其它很不错的工具,但这几个命令基本也就足够了,我自己用得最多的也就是这几个,比如遇到电脑网卡不正常工作就先用lspci看看网卡硬件是否已经找到了等等。示例用法如下:

[root@localhost ~]# lscpu
Architecture:          i686
CPU(s):                1
Thread(s) per core:    1
Core(s) per socket:    1
CPU socket(s):         1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 15
Stepping:              13
CPU MHz:               1729.001
L1d cache:             32K
L1i cache:             32K
L2 cache:              512K
[root@localhost ~]# dmidecode -t cache
# dmidecode 2.10
SMBIOS 2.4 present.

Handle 0x001C, DMI type 7, 19 bytes
Cache Information
	Socket Designation: L1 Cache
	Configuration: Enabled, Socketed, Level 1
	Operational Mode: Write Back
	Location: Internal
	Installed Size: 16 kB
	Maximum Size: 16 kB
	Supported SRAM Types:
		Burst
		Pipeline Burst
		Asynchronous
	Installed SRAM Type: Asynchronous
	Speed: Unknown
	Error Correction Type: Unknown
	System Type: Unknown
	Associativity: Unknown

...

[root@localhost ~]# dmidecode -t memory
# dmidecode 2.10
SMBIOS 2.4 present.

Handle 0x000C, DMI type 5, 46 bytes
Memory Controller Information
	Error Detecting Method: None
	Error Correcting Capabilities:
		None
	Supported Interleave: One-way Interleave
	Current Interleave: One-way Interleave
	Maximum Memory Module Size: 32768 MB
	Maximum Total Memory Size: 491520 MB
	Supported Speeds:
		70 ns
		60 ns
	Supported Memory Types:
		FPM
		EDO
		DIMM
		SDRAM
	Memory Module Voltage: 3.3 V
...

[root@localhost ~]# dmidecode -t bios
# dmidecode 2.10
SMBIOS 2.4 present.

Handle 0x0000, DMI type 0, 24 bytes
BIOS Information
	Vendor: Phoenix Technologies LTD
	Version: 6.00
	Release Date: 09/18/2009
	Address: 0xEA2E0
	Runtime Size: 89376 bytes
	ROM Size: 64 kB
	Characteristics:
		ISA is supported
		PCI is supported
		PC Card (PCMCIA) is supported
		PNP is supported
		APM is supported
		BIOS is upgradeable
		BIOS shadowing is allowed
		ESCD support is available
		USB legacy is supported
		Smart battery is supported
		BIOS boot specification is supported
		Targeted content distribution is supported
	BIOS Revision: 4.6
	Firmware Revision: 0.0

[root@localhost ~]# lspci -t -vv
-[0000:00]-+-00.0  Intel Corporation 440BX/ZX/DX - 82443BX/ZX/DX Host bridge
           +-01.0-[01]--
           +-07.0  Intel Corporation 82371AB/EB/MB PIIX4 ISA
           +-07.1  Intel Corporation 82371AB/EB/MB PIIX4 IDE
           +-07.3  Intel Corporation 82371AB/EB/MB PIIX4 ACPI
           +-07.7  VMware Virtual Machine Communication Interface
           +-0f.0  VMware SVGA II Adapter
           +-10.0  LSI Logic / Symbios Logic 53c1030 PCI-X Fusion-MPT Dual Ultra320 SCSI
           +-11.0-[02]--+-00.0  Intel Corporation 82371AB/EB/MB PIIX4 USB
           |            +-01.0  Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
           |            +-02.0  Ensoniq ES1371 [AudioPCI-97]
           |            \-03.0  VMware USB2 EHCI Controller
...

[root@localhost ~]# smartctl -i /dev/sda1
smartctl 5.39.1 2010-01-28 r3054 [i686-pc-linux-gnu] (local build)
Copyright (C) 2002-10 by Bruce Allen, http://smartmontools.sourceforge.net

Device: VMware,  VMware Virtual S Version: 1.0 
Device type: disk
Local Time is: Tue Nov 29 23:36:19 2011 EST
Device does not support SMART
[root@localhost ~]# lsusb
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

转载请保留地址:http://www.lenky.info/archives/2011/12/534http://lenky.info/?p=534


备注:如无特殊说明,文章内容均出自Lenky个人的真实理解而并非存心妄自揣测来故意愚人耳目。由于个人水平有限,虽力求内容正确无误,但仍然难免出错,请勿见怪,如果可以则请留言告之,并欢迎来讨论。另外值得说明的是,Lenky的部分文章以及部分内容参考借鉴了网络上各位网友的热心分享,特别是一些带有完全参考的文章,其后附带的链接内容也许更直接、更丰富,而我只是做了一下归纳&转述,在此也一并表示感谢。关于本站的所有技术文章,欢迎转载,但请遵从CC创作共享协议,而一些私人性质较强的心情随笔,建议不要转载。

法律:根据最新颁布的《信息网络传播权保护条例》,如果您认为本文章的任何内容侵犯了您的权利,请以Email或书面等方式告知,本站将及时删除相关内容或链接。

  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.