Linux硬體資訊查詢命令

來源:互聯網
上載者:User

Linux硬體資訊查詢命令

系統

uname -a # 查看核心/作業系統/CPU資訊
Linux hostname 2.6.18-128.el5 #1 SMP Wed Dec 17 11:41:38 EST 2008 x86_64 x86_64 x86_64 GNU/Linux
head -n 1 /etc/issue # 查看作業系統版本
Red Hat Enterprise Linux Server release 5.3 (Tikanga)
cat /proc/cpuinfo # 查看CPU資訊
processor       : 0vendor_id       : GenuineIntelcpu family      : 6model           : 44model name      : Intel(R) Xeon(R) CPU           X5670  @ 2.93GHzstepping        : 2cpu MHz         : 2933.582cache size      : 12288 KBphysical id     : 1siblings        : 12core id         : 0cpu cores       : 6apicid          : 32fpu             : yesfpu_exception   : yescpuid level     : 11wp              : yesflags           : 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 ht tm syscall nx pdpe1gb rdtscp lm constant_tsc ida pni monitor ds_cpl vmx smx est tm2 cx16 xtpr popcnt lahf_lmbogomips        : 5871.13clflush size    : 64cache_alignment : 64address sizes   : 40 bits physical, 48 bits virtualpower management:
hostname # 查看電腦主機名稱  
hostname.com.cn
lspci -tv # 列出所有PCI裝置
-[0000:00]-+-00.0  Intel Corporation 5500 I/O Hub to ESI Port           +-01.0-[02]--+-00.0  Broadcom Corporation NetXtreme II BCM57711E 10-G                       igabit PCIe           |            \-00.1  Broadcom Corporation NetXtreme II BCM57711E 10-G                       igabit PCIe           +-02.0-[0d]--           +-03.0-[03-05]--           +-07.0-[06-08]--           +-08.0-[11]--           +-09.0-[09-0b]--+-00.0  QLogic Corp. ISP2432-based 4Gb Fibre Channel  
lsusb -tv # 列出所有USB裝置
Bus#  6`-Dev#   1 Vendor 0x0000 Product 0x0000`-Dev#   2 Vendor 0x03f0 Product 0x1027Bus#  5`-Dev#   1 Vendor 0x0000 Product 0x0000Bus#  4`-Dev#   1 Vendor 0x0000 Product 0x0000Bus#  3`-Dev#   1 Vendor 0x0000 Product 0x0000Bus#  2`-Dev#   1 Vendor 0x0000 Product 0x0000Bus#  1`-Dev#   1 Vendor 0x0000 Product 0x0000
lsmod # 列出載入的核心模組 env # 查看環境變數資源
_=/bin/envCVS_RSH=sshG_BROKEN_FILENAMES=1HISTSIZE=1000HOME=/rootINPUTRC=/etc/inputrcKDEDIR=/usrKDE_IS_PRELINKED=1KDE_NO_IPV6=1LANG=en_US.UTF-8LESSOPEN=|/usr/bin/lesspipe.sh %sLOGNAME=rootMAIL=/var/spool/mail/rootPATH=/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 # 查看記憶體使用量量和交換區使用量
             total       used       free     shared    buffers     cachedMem:         48295       9647      38648       0       1165        4067-/+ buffers/cache:       4413      43881Swap:         3999          0       3999 
df -h # 查看各分區使用方式

 

Filesystem            Size  Used   Avail   Use%      Mounted on/dev/mapper/rootVG-root                       83G  7.4G   72G     10%      //dev/mapper/rootVG-tmp                      3.9G  137M  3.6G     4%       /tmp/dev/mapper/rootVG-var                       31G  5.1G   24G     18%      /var
du -sh <目錄名> # 查看指定目錄的大小

 

# du -sh /tmp84K     /tmp
grep MemTotal /proc/meminfo # 查看記憶體總量

 

<pre name="code" class="plain"># <span style="font-family: Arial, Helvetica, sans-serif;">grep MemTotal /proc/meminfo</span>
MemTotal: 16432172 kB 

grep MemFree /proc/meminfo # 查看空閑記憶體量

# grep MemFree /proc/meminfoMemFree:      12647164 kB
uptime # 查看系統已耗用時間、使用者數、負載
14:15:28 up 4 days,  2:56,  1 user,  load average: 1.17, 1.15, 1.10
cat /proc/loadavg # 查看系統負載
# cat /proc/loadavg1.11 1.14 1.09 1/546 5175

磁碟和分區

mount | column -t # 查看掛接的分區狀態
/dev/mapper/rootVG-root     on  /         type  ext3    (rw)proc                        on  /proc     type  proc    (rw)sysfs                       on  /sys      type  sysfs   (rw)devpts                      on  /dev/pts  type  devpts  (rw,gid=5,mode=620)/dev/mapper/rootVG-tmp      on  /tmp      type  ext3    (rw)
fdisk -l # 查看所有分區
Disk /dev/cciss/c0d0: 146.7 GB, 146778685440 bytes255 heads, 63 sectors/track, 17844 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes           Device Boot      Start         End      Blocks   Id  System/dev/cciss/c0d0p1   *           1          19      152586   83  Linux/dev/cciss/c0d0p2              20       17844   143179312+  8e  Linux LVMDisk /dev/sdc: 384.3 GB, 384399572992 bytes255 heads, 63 sectors/track, 46733 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDisk /dev/sdc doesn't contain a valid partition tableDisk /dev/sde: 225.4 GB, 225485783040 bytes255 heads, 63 sectors/track, 27413 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes
swapon -s # 查看所有交換分區
Filename                                Type            Size    Used    Priority/dev/mapper/rootVG-swap                 partition       16777208        0       -1
hdparm -i /dev/hda # 查看磁碟參數(僅適用於IDE裝置)dmesg | grep IDE # 查看啟動時IDE裝置檢測狀況
Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2Probing IDE interface ide0...Probing IDE interface ide1... 

網路

ifconfig # 查看所有網路介面的屬性
bond0     Link encap:Ethernet  HWaddr F4:CE:46:7E:D7:68          inet addr:10.56.236.101  Bcast:10.56.236.127  Mask:255.255.255.128          UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1          RX packets:196625663 errors:0 dropped:0 overruns:0 frame:0          TX packets:166879878 errors:0 dropped:0 overruns:0 carrier:0          collisions:0 txqueuelen:0          RX bytes:30475502617 (28.3 GiB)  TX bytes:34248137790 (31.8 GiB)eth0      Link encap:Ethernet  HWaddr F4:CE:46:7E:D7:68          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1          RX packets:196625663 errors:0 dropped:0 overruns:0 frame:0          TX packets:166879878 errors:0 dropped:0 overruns:0 carrier:0          collisions:0 txqueuelen:1000          RX bytes:30475502617 (28.3 GiB)  TX bytes:34248137790 (31.8 GiB)          Interrupt:130 Memory:fb000000-fb7fffff
iptables -L # 查看防火牆設定
Chain INPUT (policy ACCEPT)target     prot opt source               destinationChain FORWARD (policy ACCEPT)target     prot opt source               destinationChain OUTPUT (policy ACCEPT)target     prot opt source               destination
route -n # 查看路由表
Kernel IP routing tableDestination     Gateway         Genmask         Flags Metric Ref    Use Iface10.56.236.0     0.0.0.0         255.255.255.128 U     0      0        0 bond0169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 bond00.0.0.0         10.56.236.126   0.0.0.0         UG    0      0        0 bond0
netstat -lntp # 查看所有監聽連接埠
Active Internet connections (only servers)Proto Recv-Q Send-Q Local Address               Foreign Address                                                  State       PID/Program nametcp        0      0 0.0.0.0:2049                0.0.0.0:*                                                        LISTEN      -tcp        0      0 0.0.0.0:389                 0.0.0.0:*                                                        LISTEN      12782/ns-slapd  # netstat -antp # 查看所有已經建立的串連Active Internet connections (servers and established)Proto Recv-Q Send-Q Local Address               Foreign Address                                                  State       PID/Program nametcp        0      0 0.0.0.0:2049                0.0.0.0:*                                                        LISTEN      -tcp        0      0 0.0.0.0:389                 0.0.0.0:*                                                        LISTEN      12782/ns-slapdtcp        0      0 0.0.0.0:11111               0.0.0.0:*                                                        LISTEN      15217/ricci
netstat -s # 查看網路統計資訊
Ip:    195815097 total packets received    8 forwarded    0 incoming packets discarded    195814891 incoming packets delivered    167012221 requests sent out    3 outgoing packets dropped    7 fragments dropped after timeout    231 reassemblies required    33 packets reassembled ok    7 packet reassembles failed    8 fragments received ok    32 fragments createdIcmp:    25034 ICMP messages received    16 input ICMP message failed.    ICMP input histogram:        destination unreachable: 173        echo requests: 13025        echo replies: 11836    25060 ICMP messages sent    0 ICMP messages failed    ICMP output histogram:        destination unreachable: 185        echo request: 11842        echo replies: 13025IcmpMsg:        InType0: 11836        InType3: 173        InType8: 13025        OutType0: 13025        OutType3: 185        OutType8: 11842        OutType10: 8

進程

ps -ef # 查看所有進程

UID        PID  PPID  C STIME TTY      TIME CMDroot         1     0  0 Jul10 ?        00:00:05 init [3]root         2     1  0 Jul10 ?        00:00:03 [migration/0]root         3     1  0 Jul10 ?        00:00:00 [ksoftirqd/0]root         4     1  0 Jul10 ?        00:00:00 [watchdog/0]

top # 即時顯示進程狀態

Tasks: 385 total,   1 running, 384 sleeping,   0 stopped,   0 zombieCpu(s):  0.2%us,  0.3%sy,  0.0%ni, 98.6%id,  0.8%wa,  0.0%hi,  0.1%si,  0.0%stMem:  16432172k total,  3795132k used, 12637040k free,   800952k buffersSwap: 16777208k total,        0k used, 16777208k free,  1729708k cached  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND 7339 root      15   0 11016 1192  700 R  2.0  0.0   0:00.01 top17378 root      10  -5     0    0    0 D  2.0  0.0   6:50.74 kjournald    1 root      15   0 10372  704  596 S  0.0  0.0   0:05.31 init

使用者

w # 查看活動使用者
 14:33:53 up 4 days,  3:15,  1 user,  load average: 1.17, 1.14, 1.10USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHATroot     pts/0    10.141.41.62     13:11    0.00s  0.05s  0.05s -bash
id <使用者名稱> # 查看指定使用者資訊
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
last # 查看使用者登入日誌
root     pts/0        10.141.41.62     Mon Jul 14 13:11   still logged inroot     pts/0        10.141.41.62     Mon Jul 14 10:38 - 12:34  (01:56)root     pts/0        10.141.152.51    Sun Jul 13 07:14 - 11:55  (04:41)root     pts/2        10.140.2.76      Fri Jul 11 17:50 - 18:38  (00:47)
cut -d: -f1 /etc/passwd # 查看系統所有使用者 
# cut -d: -f1 /etc/passwdrootbindaemonadm
cut -d: -f1 /etc/group # 查看系統所有組
rootbindaemonsysadmttydisk
crontab -l # 查看目前使用者的計劃任務

服務

chkconfig --list # 列出所有系統服務
httpd           0:off   1:off   2:off   3:off   4:off   5:off   6:offip6tables       0:off   1:off   2:on    3:on    4:on    5:on    6:offnetwork         0:off   1:off   2:on    3:on    4:on    5:on    6:offnfs             0:off   1:off   2:off   3:off   4:off   5:off   6:offnfslock         0:off   1:off   2:off   3:on    4:on    5:on    6:offnscd            0:off   1:off   2:on    3:on    4:on    5:on    6:offntpd            0:off   1:off   2:on    3:on    4:on    5:on    6:offoddjobd         0:off   1:off   2:off   3:off   4:off   5:off   6:offoractl          0:off   1:off   2:off   3:off   4:off   5:off   6:offsnmpd           0:off   1:off   2:on    3:on    4:on    5:on    6:offsnmptrapd       0:off   1:off   2:off   3:off   4:off   5:off   6:offsshd            0:off   1:off   2:on    3:on    4:on    5:on    6:offsyslog          0:off   1:off   2:on    3:on    4:on    5:on    6:off
chkconfig –list | grep on # 列出所有啟動的系統服務

程式

rpm -qa # 查看所有安裝的軟體包
# rpm -qa | grep perlperl-HTML-Parser-3.55-1.fc6perl-Net-Telnet-3.03-5perl-LDAP-0.33-4.el5_8perl-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查看已載入的驅動:  lsnod lshw查看當前處理器的類型和速度(主頻):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 進程資訊偽裝檔案系統

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.