Linux下硬件信息查看

以前linux对硬件的支持不怎么好这是大家普遍的印象,然而现在的linux发行版本对硬件的支持度已经算非常好了,普通的硬件像显卡,声卡等更笨不需要安装任何驱动就可以在linux下直接使用。只不过有时候为了更好地发挥硬件的性能,我们最好还是给硬件安装上驱动。安装驱动首先需要获得硬件的信息,特别是核心芯片的提供厂商。一般的我们都知道CPU的提供厂商有Intel和AMD两个,显卡的提供厂商有ATI,NVIDIA,SIS等。声卡呢,最常见的是创新提供的声卡。一般来说,像显卡,声卡,网卡这样的板卡的制造厂商都只是购买了核心芯片,然后在芯片周围做些外围的电路扩展以实现芯片的功能。这样就可以拿来卖给我们钱了。

Linux对硬件支持的原理:linux只是简单的读取硬件的芯片信息用来和自己库里的驱动程序比较,发现有匹配的程序就用该驱动程序来加载硬件,实现各种功能

当然,linux提供我们各种查询硬件信息的命令:

  • 查看PCI设备

系统中大多数设置都是PCI设备(网卡,声卡,1394火线接口,集成显卡等)
root@bt:/proc# lspci -v                                        #详细pci状态信息
root@bt:/proc# lspci -vv                                      #比上面的更详细
root@bt:/proc# lspci -vvv                                    #比上面的更更详细
root@bt:/proc# lspci -n                                       #显示设备商和设备代码
root@bt:/proc# lspci -nn                                     #比上面的详细,多了名字
root@bt:/proc# lspci -nnn                                   #比上面的更详细
root@bt:/proc# lspci -x                                       #显示硬件基本配置的二进制信息
root@bt:/proc# lspci -xxx                                    #比上面的详细
root@bt:/proc# lspci -xxxx                                  #比上面的更详细
root@bt:/proc# lspci -vvx                                    #可以组合着查看
root@bt:/proc# lspci -vvxxx                                 #组合着查看
注释:lspci是从pciids数据库读取硬件信息的,如果出现硬件无法识别,可以使用sudo update-pciide更新pci数据库。上面的命令查询结果在你的pci硬件出现问题的时候将其在网上公布,有热心网友或厂商会帮你解决的。

  • 查看内核信息

root@bt:/proc# uname -a
Linux bt 2.6.38 #1 SMP Thu Mar 17 20:52:18 EDT 2011 i686 GNU/Linux
root@bt:/proc# uname –help
Usage: uname [OPTION]…
Print certain system information. With no OPTION, same as -s.

-a, –all print all information, in the following order,
except omit -p and -i if unknown:
-s, –kernel-name print the kernel name
-n, –nodename print the network node hostname
-r, –kernel-release print the kernel release
-v, –kernel-version print the kernel version
-m, –machine print the machine hardware name
-p, –processor print the processor type or “unknown”
-i, –hardware-platform print the hardware platform or “unknown”
-o, –operating-system print the operating system
–help display this help and exit
–version output version information and exit

  • 查看Ubuntu发行版本

root@bt:/proc# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 10.04.2 LTS
Release: 10.04
Codename: lucid                          #发行版本代号

  • 查看内核加载模块

root@bt:/proc# lsmod

  • 查看usb设备使用情况

root@bt:/proc# 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
注释:如果usb设备未被占用,ID号会显示:0000:0000
root@bt:/proc# lsusb -v               #输出详细的USB信息

  • 查看网卡状态

root@bt:/proc# ethtool eth0                                 #查看第一个网卡(eth0)的状态信息
Settings for eth0:
Supported ports: [ TP ]
Supported link modes: 1000baseT/Full                #1000M全双工网卡
Supports auto-negotiation: No                             #不支持自协商
Advertised link modes: Not reported
Advertised pause frame use: No
Advertised auto-negotiation: No
Link partner advertised link modes: Not reported
Link partner advertised pause frame use: No
Link partner advertised auto-negotiation: No
Speed: 1000Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 0
Transceiver: internal
Auto-negotiation: off
MDI-X: Unknown
Link detected: yes

  • 查看CPU信息

root@bt:/proc# cat cpuinfo
processor : 0                                                            #编号
vendor_id : GenuineIntel                                            #intel架构
cpu family : 6                                                          #体系编号
model : 23                                                               #型号
model name : Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz        #名称,主频
stepping : 10                                                           #倍频
cpu MHz : 2534.000                                               #实际速度
cache size : 3072 KB                                              #缓存大小
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss nx lm constant_tsc up arch_perfmon pebs bts xtopology tsc_reliable aperfmperf pni ssse3 cx16 sse4_1 hypervisor lahf_lm ida dts
bogomips : 5068.00
clflush size : 64
cache_alignment : 64
address sizes : 40 bits physical, 48 bits virtual
power management:

  • 查看当前硬件信息

root@bt:/proc# lshw                    #显示完整的系统硬件信息,包括内存,cpu版本…
root@bt:/proc# lshw -short            #短格式显示
root@bt:/proc# lshw -class disk     #显示磁盘信息
root@bt:/proc# lshw -class storage  #显示存储控制设备信息

  • 查看当前内存使用情况

root@bt:/proc# free
total used free shared buffers cached
Mem: 1025720 373120 652600 0 35052 207464
-/+ buffers/cache: 130604 895116
Swap: 916476 0 916476
注释:内存实际使用量看-/+ buffers/cache这一行,是130604K,Mem行是名义上的使用情况,是加上了缓存和缓冲区使用量之后的。
名义上的内存使用373120K=130604K+35052K+207464K

分享到:

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>