Linux查看物理CPU個數、核數、邏輯CPU個數
# 總核數 = 物理CPU個數 X 每顆物理CPU的核數
# 總邏輯CPU數 = 物理CPU個數 X 每顆物理CPU的核數 X 超線程數html
查看分區磁盤的速度命令
$ hdparm -Tt /dev/sda1
/dev/sda1:
Timing cached reads: 1770 MB in 2.00 seconds = 885.55 MB/sec
Timing buffered disk reads: 218 MB in 3.03 seconds = 71.92 MB/secubuntu
# 查看物理CPU個數
cat /proc/cpuinfo| grep "physical id"| sort | uniq | wc -l
k@ubuntu:~$ cat /proc/cpuinfo| grep "physical id"| sort | uniq | wc -l
1服務器
# 查看每一個物理CPU中core的個數(即核數)
cat /proc/cpuinfo| grep "cpu cores" | uniq
k@ubuntu:~$ cat /proc/cpuinfo| grep "cpu cores" | uniq
cpu cores : 2網絡
# 查看邏輯CPU的個數
cat /proc/cpuinfo| grep "processor" | wc -l
k@ubuntu:~$ cat /proc/cpuinfo| grep "processor" | wc -l
2app
# 查看CPU信息(型號)
cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
k@ubuntu:~$ cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
2 Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHzsocket
# 查看內存信息
cat /proc/meminfo
k@ubuntu:~$ cat /proc/meminfo
MemTotal: 1012356 kB
MemFree: 141456 kB
MemAvailable: 413736 kB
Buffers: 37448 kB
Cached: 356648 kB
SwapCached: 0 kB
Active: 565796 kB
Inactive: 196784 kB
Active(anon): 369300 kB
Inactive(anon): 9568 kB
Active(file): 196496 kB
Inactive(file): 187216 kB
Unevictable: 32 kB
Mlocked: 32 kB
SwapTotal: 1046524 kB
SwapFree: 1046524 kB
Dirty: 56 kB
Writeback: 0 kB
AnonPages: 368576 kB
Mapped: 174608 kB
Shmem: 10388 kB
Slab: 57892 kB
SReclaimable: 32412 kB
SUnreclaim: 25480 kB
KernelStack: 6704 kB
PageTables: 24368 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 1552700 kB
Committed_AS: 2694544 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
HardwareCorrupted: 0 kB
AnonHugePages: 79872 kB
CmaTotal: 0 kB
CmaFree: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 77744 kB
DirectMap2M: 970752 kBtcp
CPU
型號:grep "model name" /proc/cpuinfo |awk -F ':' '{print $NF}'
k@ubuntu:~$ grep "model name" /proc/cpuinfo |awk -F ':' '{print $NF}'
Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz
Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHzide
數量:lscpu | grep "CPU socket" | awk '{print $NF}' 或 lscpu | grep "Socket" | awk '{print $NF}'
k@ubuntu:~$ lscpu | grep "Socket" | awk '{print $NF}'
1ui
每一個CPU的核數:lscpu |grep "Core(s) per socket" |awk '{print $NF}'
k@ubuntu:~$ lscpu |grep "Core(s) per socket" |awk '{print $NF}'
2線程
內存:
卡槽數量:sudo dmidecode -t memory | grep "Number Of Devices" |awk '{print $NF}' 或 sudo dmidecode -t memory |grep "Associated Memory Slots" |awk '{print $NF}'
k@ubuntu:~$ sudo dmidecode -t memory | grep "Number Of Devices" |awk '{print $NF}'
8
內存數量:sudo dmidecode -t memory | grep -A16 "Memory Device$" |grep 'Size:.*MB' |wc -l
k@ubuntu:~$ sudo dmidecode -t memory | grep -A16 "Memory Device$" |grep 'Size:.*MB' |wc -l
1
內存型號:
內存支持類型:sudo dmidecode -t memory | grep -A16 "Memory Device$" | grep "Type:"
k@ubuntu:~$ sudo dmidecode -t memory | grep -A16 "Memory Device$" | grep "Type:" Type: DRAM
Type: DRAM
Type: DRAM
Type: DRAM
Type: DRAM
Type: DRAM
Type: DRAM
Type: DRAM
每一個內存頻率:sudo dmidecode -t memory | grep -A16 "Memory Device$" | grep "Speed:"
k@ubuntu:~$ sudo dmidecode -t memory | grep -A16 "Memory Device$" | grep "Speed:"
Speed: 667 MHz
Speed: 667 MHz
Speed: 667 MHz
Speed: 667 MHz
Speed: 667 MHz
Speed: 667 MHz
Speed: 667 MHz
Speed: 667 MHz
每一個內存大小:sudo dmidecode -t memory | grep -A16 "Memory Device$" | grep "Size:"
k@ubuntu:~$ sudo dmidecode -t memory | grep -A16 "Memory Device$" | grep "Size:" Size: 1024 MB
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
釋放緩衝區內存:
echo 3 > /proc/sys/vm/drop_caches
硬盤:
硬盤數量、大小:sudo fdisk -l |grep "Disk /dev/sd"
k@ubuntu:~$ sudo fdisk -l |grep "Disk /dev/sd"
Disk /dev/sda: 68.7 GB, 68719476736 bytes
硬盤型號:sudo hdparm -i /dev/sda |grep "Model"
k@ubuntu:~$ sudo hdparm -i /dev/sda |grep "Model"
Model=Ubuntu Linux-0 SSD, FwRev=F.H9RY0W, SerialNo=QAWE0TXFSH44Q2KRWWZ0
查看端口使用狀況,使用netstat命令
# 查看已經鏈接的服務端口(ESTABLISHED)
$ netstat -a
# 查看全部的服務端口(LISTEN,ESTABLISHED)
$ netstat -apn
-a或--all:顯示全部連線中的Socket;
-A<網絡類型>或--<網絡類型>:列出該網絡類型連線中的相關地址;
-c或--continuous:持續列出網絡狀態;
-C或--cache:顯示路由器配置的快取信息;
-e或--extend:顯示網絡其餘相關信息;
-F或--fib:顯示FIB;
-g或--groups:顯示多重廣播功能羣組組員名單;
-h或--help:在線幫助;
-i或--interfaces:顯示網絡界面信息表單;
-l或--listening:顯示監控中的服務器的Socket;
-M或--masquerade:顯示假裝的網絡連線;
-n或--numeric:直接使用ip地址,而不經過域名服務器;
-N或--netlink或--symbolic:顯示網絡硬件外圍設備的符號鏈接名稱;
-o或--timers:顯示計時器;
-p或--programs:顯示正在使用Socket的程序識別碼和程序名稱;
-r或--route:顯示Routing Table;
-s或--statistice:顯示網絡工做信息統計表;
-t或--tcp:顯示TCP傳輸協議的連線情況;
-u或--udp:顯示UDP傳輸協議的連線情況;
-v或--verbose:顯示指令執行過程;
-V或--version:顯示版本信息;
-w或--raw:顯示RAW傳輸協議的連線情況;
-x或--unix:此參數的效果和指定"-A unix"參數相同;
--ip或--inet:此參數的效果和指定"-A inet"參數相同。
查看指定端口,能夠結合grep命令, 也能夠使用lsof命令:
netstat -apn | grep 8080
lsof -i:8888
若要關閉使用這個端口的程序,使用kill + 對應的pid
kill -9 PID
參考:https://www.cnblogs.com/fieldtianye/p/8270091.html