Linux下硬件信息查询命令

分类:CentOS教程 阅读:28735 次

系统

  • uname -a # 查看内核/操作系统/CPU信息
  1. Linuxhostname2.6.18-128.el5#1SMPWedDec1711:41:38EST2008x86_64x86_64x86_64GNU/Linux
  • head -n 1 /etc/issue # 查看操作系统版本
  1. RedHatEnterpriseLinuxServerrelease5.3(Tikanga)
  • cat /proc/cpuinfo # 查看CPU信息
  1. processor:0
  2. vendor_id:GenuineIntel
  3. cpufamily:6
  4. model:44
  5. modelname:Intel(R)Xeon(R)CPUX5670@2.93GHz
  6. stepping:2
  7. cpuMHz:2933.582
  8. cachesize:12288KB
  9. physicalid:1
  10. siblings:12
  11. coreid:0
  12. cpucores:6
  13. apicid:32
  14. fpu:yes
  15. fpu_exception:yes
  16. cpuidlevel:11
  17. wp:yes
  18. flags:fpuvmedepsetscmsrpaemcecx8apicsepmtrrpgemcacmovpatpse36clflushdtsacpimmxfxsrssesse2sshttmsyscallnxpdpe1gbrdtscplmconstant_tscidapnimonitords_cplvmxsmxesttm2cx16xtprpopcntlahf_lm
  19. bogomips:5871.13
  20. clflushsize:64
  21. cache_alignment:64
  22. addresssizes:40bitsphysical,48bitsvirtual
  23. powermanagement:
  • hostname # 查看计算机主机名
  1. hostname.com.cn
  • lspci -tv # 列出所有PCI设备
  1. -[0000:00]-+-00.0IntelCorporation5500I/OHubtoESIPort
  2. +-01.0-[02]--+-00.0BroadcomCorporationNetXtremeIIBCM57711E10-GigabitPCIe
  3. |\-00.1BroadcomCorporationNetXtremeIIBCM57711E10-GigabitPCIe
  4. +-02.0-[0d]--
  5. +-03.0-[03-05]--
  6. +-07.0-[06-08]--
  7. +-08.0-[11]--
  8. +-09.0-[09-0b]--+-00.0QLogicCorp.ISP2432-based4GbFibreChannel
  • lsusb -tv # 列出所有USB设备
  1. Bus#6
  2. `-Dev#1Vendor0x0000Product0x0000
  3. `-Dev#2Vendor0x03f0Product0x1027
  4. Bus#5
  5. `-Dev#1Vendor0x0000Product0x0000
  6. Bus#4
  7. `-Dev#1Vendor0x0000Product0x0000
  8. Bus#3
  9. `-Dev#1Vendor0x0000Product0x0000
  10. Bus#2
  11. `-Dev#1Vendor0x0000Product0x0000
  12. Bus#1
  13. `-Dev#1Vendor0x0000Product0x0000
  • lsmod # 列出加载的内核模块
  • env # 查看环境变量资源
  1. _=/bin/env
  2. CVS_RSH=ssh
  3. G_BROKEN_FILENAMES=1
  4. HISTSIZE=1000
  5. HOME=/root
  6. INPUTRC=/etc/inputrc
  7. KDEDIR=/usr
  8. KDE_IS_PRELINKED=1
  9. KDE_NO_IPV6=1
  10. LANG=en_US.UTF-8
  11. LESSOPEN=|/usr/bin/lesspipe.sh%s
  12. LOGNAME=root
  13. MAIL=/var/spool/mail/root
  14. PATH=/usr/lib64/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  • free -m # 查看内存使用量和交换区使用量
  1. totalusedfreesharedbufferscached
  2. Mem:48295964738648011654067
  3. -/+buffers/cache:441343881
  4. Swap:399903999
  • df -h # 查看各分区使用情况
  1. FilesystemSizeUsedAvailUse%Mountedon
  2. /dev/mapper/rootVG-root
  3. 83G7.4G72G10%/
  4. /dev/mapper/rootVG-tmp
  5. 3.9G137M3.6G4%/tmp
  6. /dev/mapper/rootVG-var
  7. 31G5.1G24G18%/var
  • du -sh <目录名> # 查看指定目录的大小
  1. #du-sh/tmp
  2. 84K/tmp
  • grep MemTotal /proc/meminfo # 查看内存总量
  1. #grepMemTotal/proc/meminfo
  2. MemTotal:16432172kB
  • grep MemFree /proc/meminfo # 查看空闲内存量
  1. #grepMemFree/proc/meminfo
  2. MemFree:12647164kB
  • uptime # 查看系统运行时间、用户数、负载
  1. 14:15:28up4days,2:56,1user,loadaverage:1.17,1.15,1.10
  • cat /proc/loadavg # 查看系统负载
  1. #cat/proc/loadavg
  2. 1.111.141.091/5465175


磁盘和分区

  • mount | column -t # 查看挂接的分区状态
  1. /dev/mapper/rootVG-rooton/typeext3(rw)
  2. procon/proctypeproc(rw)
  3. sysfson/systypesysfs(rw)
  4. devptson/dev/ptstypedevpts(rw,gid=5,mode=620)
  5. /dev/mapper/rootVG-tmpon/tmptypeext3(rw)
  • fdisk -l # 查看所有分区
  1. Disk/dev/cciss/c0d0:146.7GB,146778685440bytes
  2. 255heads,63sectors/track,17844cylinders
  3. Units=cylindersof16065*512=8225280bytes
  4. DeviceBootStartEndBlocksIdSystem
  5. /dev/cciss/c0d0p1*11915258683Linux
  6. /dev/cciss/c0d0p22017844143179312+8eLinuxLVM
  7. Disk/dev/sdc:384.3GB,384399572992bytes
  8. 255heads,63sectors/track,46733cylinders
  9. Units=cylindersof16065*512=8225280bytes
  10. Disk/dev/sdcdoesn'tcontainavalidpartitiontable
  11. Disk/dev/sde:225.4GB,225485783040bytes
  12. 255heads,63sectors/track,27413cylinders
  13. Units=cylindersof16065*512=8225280bytes
  • swapon -s # 查看所有交换分区
  1. FilenameTypeSizeUsedPriority
  2. /dev/mapper/rootVG-swappartition167772080-1
  • hdparm -i /dev/hda # 查看磁盘参数(仅适用于IDE设备)
  • dmesg | grep IDE # 查看启动时IDE设备检测状况
  1. UniformMulti-PlatformE-IDEdriverRevision:7.00alpha2
  2. ProbingIDEinterfaceide0...
  3. ProbingIDEinterfaceide1...


网络

  • ifconfig # 查看所有网络接口的属性
  1. bond0Linkencap:EthernetHWaddrF4:CE:46:7E:D7:68
  2. inetaddr:10.56.236.101Bcast:10.56.236.127Mask:255.255.255.128
  3. UPBROADCASTRUNNINGMASTERMULTICASTMTU:1500Metric:1
  4. RXpackets:196625663errors:0dropped:0overruns:0frame:0
  5. TXpackets:166879878errors:0dropped:0overruns:0carrier:0
  6. collisions:0txqueuelen:0
  7. RXbytes:30475502617(28.3GiB)TXbytes:34248137790(31.8GiB)
  8. eth0Linkencap:EthernetHWaddrF4:CE:46:7E:D7:68
  9. UPBROADCASTRUNNINGSLAVEMULTICASTMTU:1500Metric:1
  10. RXpackets:196625663errors:0dropped:0overruns:0frame:0
  11. TXpackets:166879878errors:0dropped:0overruns:0carrier:0
  12. collisions:0txqueuelen:1000
  13. RXbytes:30475502617(28.3GiB)TXbytes:34248137790(31.8GiB)
  14. Interrupt:130Memory:fb000000-fb7fffff
  • iptables -L # 查看防火墙设置
  1. ChainINPUT(policyACCEPT)
  2. targetprotoptsourcedestination
  3. ChainFORWARD(policyACCEPT)
  4. targetprotoptsourcedestination
  5. ChainOUTPUT(policyACCEPT)
  6. targetprotoptsourcedestination
  • route -n # 查看路由表
  1. KernelIProutingtable
  2. DestinationGatewayGenmaskFlagsMetricRefUseIface
  3. 10.56.236.00.0.0.0255.255.255.128U000bond0
  4. 169.254.0.00.0.0.0255.255.0.0U000bond0
  5. 0.0.0.010.56.236.1260.0.0.0UG000bond0
  • netstat -lntp # 查看所有监听端口
  1. ActiveInternetconnections(onlyservers)
  2. ProtoRecv-QSend-QLocalAddressForeignAddressStatePID/Programname
  3. tcp000.0.0.0:20490.0.0.0:*LISTEN-
  4. tcp000.0.0.0:3890.0.0.0:*LISTEN12782/ns-slapd
  5.   #netstat-antp#查看所有已经建立的连接
  6. ActiveInternetconnections(serversandestablished)
  7. ProtoRecv-QSend-QLocalAddressForeignAddressStatePID/Programname
  8. tcp000.0.0.0:20490.0.0.0:*LISTEN-
  9. tcp000.0.0.0:3890.0.0.0:*LISTEN12782/ns-slapd
  10. tcp000.0.0.0:111110.0.0.0:*LISTEN15217/ricci
  • netstat -s # 查看网络统计信息
  1. Ip:
  2. 195815097totalpacketsreceived
  3. 8forwarded
  4. 0incomingpacketsdiscarded
  5. 195814891incomingpacketsdelivered
  6. 167012221requestssentout
  7. 3outgoingpacketsdropped
  8. 7fragmentsdroppedaftertimeout
  9. 231reassembliesrequired
  10. 33packetsreassembledok
  11. 7packetreassemblesfailed
  12. 8fragmentsreceivedok
  13. 32fragmentscreated
  14. Icmp:
  15. 25034ICMPmessagesreceived
  16. 16inputICMPmessagefailed.
  17. ICMPinputhistogram:
  18. destinationunreachable:173
  19. echorequests:13025
  20. echoreplies:11836
  21. 25060ICMPmessagessent
  22. 0ICMPmessagesfailed
  23. ICMPoutputhistogram:
  24. destinationunreachable:185
  25. echorequest:11842
  26. echoreplies:13025
  27. IcmpMsg:
  28. InType0:11836
  29. InType3:173
  30. InType8:13025
  31. OutType0:13025
  32. OutType3:185
  33. OutType8:11842
  34. OutType10:8

进程
  • ps -ef # 查看所有进程
  1. UIDPIDPPIDCSTIMETTYTIMECMD
  2. root100Jul10?00:00:05init[3]
  3. root210Jul10?00:00:03[migration/0]
  4. root310Jul10?00:00:00[ksoftirqd/0]
  5. root410Jul10?00:00:00[watchdog/0]
  • top # 实时显示进程状态
  1. Tasks:385total,1running,384sleeping,0stopped,0zombie
  2. Cpu(s):0.2%us,0.3%sy,0.0%ni,98.6%id,0.8%wa,0.0%hi,0.1%si,0.0%st
  3. Mem:16432172ktotal,3795132kused,12637040kfree,800952kbuffers
  4. Swap:16777208ktotal,0kused,16777208kfree,1729708kcached
  5. PIDUSERPRNIVIRTRESSHRS%CPU%MEMTIME+COMMAND
  6. 7339root150110161192700R2.00.00:00.01top
  7. 17378root10-5000D2.00.06:50.74kjournald
  8. 1root15010372704596S0.00.00:05.31init

用户

  • w # 查看活动用户
  1. 14:33:53up4days,3:15,1user,loadaverage:1.17,1.14,1.10
  2. USERTTYFROMLOGIN@IDLEJCPUPCPUWHAT
  3. rootpts/010.141.41.6213:110.00s0.05s0.05s-bash
  • id <用户名># 查看指定用户信息
  1. uid=0(root)gid=0(root)groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
  • last # 查看用户登录日志
  1. rootpts/010.141.41.62MonJul1413:11stillloggedin
  2. rootpts/010.141.41.62MonJul1410:38-12:34(01:56)
  3. rootpts/010.141.152.51SunJul1307:14-11:55(04:41)
  4. rootpts/210.140.2.76FriJul1117:50-18:38(00:47)
  • cut -d: -f1 /etc/passwd # 查看系统所有用户
  1. #cut-d:-f1/etc/passwd
  2. root
  3. bin
  4. daemon
  5. adm
  • cut -d: -f1 /etc/group # 查看系统所有组
  1. root
  2. bin
  3. daemon
  4. sys
  5. adm
  6. tty
  7. disk
  • crontab -l # 查看当前用户的计划任务

服务

  • chkconfig --list # 列出所有系统服务
  1. httpd0:off1:off2:off3:off4:off5:off6:off
  2. ip6tables0:off1:off2:on3:on4:on5:on6:off
  3. network0:off1:off2:on3:on4:on5:on6:off
  4. nfs0:off1:off2:off3:off4:off5:off6:off
  5. nfslock0:off1:off2:off3:on4:on5:on6:off
  6. nscd0:off1:off2:on3:on4:on5:on6:off
  7. ntpd0:off1:off2:on3:on4:on5:on6:off
  8. oddjobd0:off1:off2:off3:off4:off5:off6:off
  9. oractl0:off1:off2:off3:off4:off5:off6:off
  10. snmpd0:off1:off2:on3:on4:on5:on6:off
  11. snmptrapd0:off1:off2:off3:off4:off5:off6:off
  12. sshd0:off1:off2:on3:on4:on5:on6:off
  13. syslog0:off1:off2:on3:on4:on5:on6:off
  • chkconfig –list | grep on # 列出所有启动的系统服务

程序

  • rpm -qa # 查看所有安装的软件包
  1. #rpm-qa|grepperl
  2. perl-HTML-Parser-3.55-1.fc6
  3. perl-Net-Telnet-3.03-5
  4. perl-LDAP-0.33-4.el5_8
  5. perl-XML-LibXML-1.58-6

其他常用命令整理如下:

  • 查看主板的序列号:dmidecode | grep -i 'serial number'
  • 用硬件检测程序kuduz探测新硬件:service kudzu start ( or restart)
  • 查看CPU信息:cat /proc/cpuinfo [dmesg | grep -i 'cpu'][dmidecode -t processor]
  • 查看内存信息:cat /proc/meminfo [free -m][vmstat]
  • 查看板卡信息:cat /proc/pci
  • 查看显卡/声卡信息:lspci |grep -i 'VGA'[dmesg | grep -i 'VGA']
  • 查看网卡信息:dmesg | grep -i 'eth'[cat /etc/sysconfig/hwconf | grep -i eth][lspci | grep -i 'eth']
  • 查看PCI信息:lspci (相比cat /proc/pci更直观)
  • 查看USB设备:cat /proc/bus/usb/devices
  • 查看键盘和鼠标:cat /proc/bus/input/devices
  • 查看系统硬盘信息和使用情况:fdisk & disk – l & df
  • 查看各设备的中断请求(IRQ):cat /proc/interrupts
  • 查看系统体系结构:uname -a
  • 查看及启动系统的32位或64位内核模式:isalist –v [isainfo –v][isainfo –b]
  • 查看硬件信息,包括bios、cpu、内存等信息:dmidecode
  • 测定当前的显示器刷新频率:/usr/sbin/ffbconfig –rev ?
  • 查看系统配置:/usr/platform/sun4u/sbin/prtdiag –v
  • 查看当前系统中已经应用的补丁:showrev –p
  • 显示当前的运行级别:who –rH
  • 查看当前的bind版本信息:nslookup –class=chaos –q=txt version.bind
  • 查看硬件信息:dmesg | more
  • 显示外设信息, 如usb,网卡等信息:lspci
  • 查看已加载的驱动:  lsnodlshw
  • 查看当前处理器的类型和速度(主频):psrinfo -v
  • 打印当前的OBP版本号:prtconf -v
  • 查看硬盘物理信息(vendor, RPM, Capacity):iostat –E
  • 查看磁盘的几何参数和分区信息:prtvtoc /dev/rdsk/c0t0d0s
  • 显示已经使用和未使用的i-node数目:

  df –F ufs –o i

  isalist –v

对于“/proc”中文件可使用文件查看命令浏览其内容,文件中包含系统特定信息:

  主机CPU信息:Cpuinfo

  主机DMA通道信息:Dma

  文件系统信息:Filesystems

  主机中断信息:Interrupts

  主机I/O端口号信息:Ioprots

  主机内存信息:Meninfo

  Linux内存版本信息:Version

  备注: proc – process information pseudo-filesystem 进程信息伪装文件系统