Linux 查看系統硬件信息匯總 (部份實例詳解Centoso為例)


1.cpu 

查看CPU信息
# 總核數 = 物理CPU個數 X 每顆物理CPU的核數 
# 總邏輯CPU數 = 物理CPU個數 X 每顆物理CPU的核數 X 超線程數

# 查看物理CPU個數
cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l

# 查看每個物理CPU中core的個數(即核數)
cat /proc/cpuinfo| grep "cpu cores"| uniq

# 查看邏輯CPU個數
cat /proc/cpuinfo| grep "processor"| wc -l

# 查看CPU信息(型號)
cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c

#lscpu命令,查看的是cpu的統計信息.(部分舊版本不支持)

 

Disk /dev/sda: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0000859f

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        7833    62401536   8e  Linux LVM

Disk /dev/mapper/vg_qdy-lv_root: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

 

 

使用#cat  /proc/cpuinfo ,可以知道每個cpu信息,如每個CPU的型號,主頻等。


2.內存

#free -m # 查看內存使用量和交換區使用量   

  total       used       free     shared    buffers     cached
Mem:          3690        288       3401          0         15        119
-/+ buffers/cache:        153       3536
Swap:         3951          0       3951

 # cat /proc/meminfo 

#dmidecode -t memory 查看內存硬件信息

 

grep MemTotal /proc/meminfo# 查看內存總量

grep MemFree /proc/meminfo # 查看空閑內存量

lsmod # 列出加載的內核模塊


3.磁盤

# lsblk 查看硬盤與分區分而

1 NAME                      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
2 sda                         8:0    0   60G  0 disk 
3 ├─sda1                      8:1    0  500M  0 part /boot
4 └─sda2                      8:2    0 59.5G  0 part 
5   ├─vg_qdy-lv_root (dm-0) 253:0    0   50G  0 lvm  /
6   ├─vg_qdy-lv_swap (dm-1) 253:1    0  3.9G  0 lvm  [SWAP]
7   └─vg_qdy-lv_home (dm-2) 253:2    0  5.7G  0 lvm  /home
8 sr0                        11:0    1 1024M  0 rom  
View Code

 

#df -h    # 查看各分區使用情況

#du -sh # 查看指定目錄的大小

Filesystem                  Size  Used Avail Use% Mounted on
/dev/mapper/vg_qdy-lv_root   50G  3.7G   44G   8% /
tmpfs                       1.9G     0  1.9G   0% /dev/shm
/dev/sda1                   485M   39M  421M   9% /boot
/dev/mapper/vg_qdy-lv_home  5.6G  239M  5.1G   5% /home

#fdisk -l # 查看所有分區詳細信息

Disk /dev/sda: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0000859f
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        7833    62401536   8e  Linux LVM
Disk /dev/mapper/vg_qdy-lv_root: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
...... 下方省略!

 


4.網卡信息

# lspci | grep -i 'eth'  查看網卡硬件信息

# ifconfig -a 查看系統所有網絡接口

或 #ip link show 

# ethtool eth0 查看某個網絡接口的詳細信息


5.主板所有硬件槽PCI信息。

#lspci

更詳細的lspci -v 或者 lspci -vv

#lscpi -t 設備樹


6.查看bios 信息

# dmidecode -t bios


7. 查看系統運行時間、用戶數、負載

#uptime 

#cat /proc/loadavg # 查看系統負載磁盤和分區

8. 查看掛接的分區狀態

#mount | column -t

9. 查看系統負載 磁盤和分區

# cat /proc/loadavg 

10.查看所有安裝的軟件包

 #rpm -qa

11. 查看所有進程

# ps -ef 

12. 查看所有監聽端口

#netstat -lntp 

13.查用戶與組信息

#cut -d: -f1 /etc/passwd # 查看系統所有用戶 cat /etc/passwd |more 顯示長系統用戶並分頁

#cut -d: -f1 /etc/group # 查看系統所有組   cat /etc/group|more 顯示長系統所有組並分頁

14其它不常用查看信息命令

swapon -s # 查看所有交換分區

iptables -L # 查看防火牆設置

hdparm -i /dev/hda # 查看磁盤參數(僅適用於IDE設備)

dmesg | grep IDE # 查看啟動時IDE設備檢測狀況網絡

crontab -l # 查看當前用戶的計划任務 服務

chkconfig –list # 列出所有系統服務#

chkconfig –list | grep on # 列出所有啟動的系統服務 程序


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM