系统相关
首页 > 系统相关> > ubuntu 14.04 系统配置磁盘,CPU,内存,硬盘信息查看

ubuntu 14.04 系统配置磁盘,CPU,内存,硬盘信息查看

作者:互联网

 

Linux查看物理CPU个数、核数、逻辑CPU个数
# 总核数 = 物理CPU个数 X 每颗物理CPU的核数
# 总逻辑CPU数 = 物理CPU个数 X 每颗物理CPU的核数 X 超线程数


查看分区磁盘的速度命令
$ 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/sec


# 查看物理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
2


# 查看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.10GHz


# 查看内存信息
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 kB

 

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.10GHz


数量:lscpu | grep "CPU socket" | awk '{print $NF}' 或 lscpu | grep "Socket" | awk '{print $NF}'
k@ubuntu:~$ lscpu | grep "Socket" | awk '{print $NF}'
1


每个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

 

 

标签:grep,sudo,14.04,ubuntu,proc,CPU,Size
来源: https://www.cnblogs.com/sea-stream/p/11216561.html