# 总核数 = 物理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
# 查看内 存信息
cat /proc/meminfo
# 获取CPU使用率
top -b -n1 | fgrep "Cpu(s)" | tail -1 | awk -F'id,' '{split($1, vs, ","); v=vs[length(vs)]; sub(/\s+/, "", v);sub(/\s+/, "", v); printf "%s\n", 100-v; }'
# 替换换行符
sed ':a;N;$!ba;s/\n/ /g' file.txt
# 获取IP地址
ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"
ifconfig|sed -n '/inet addr/s/^[^:]*:\([0-9.]\{7,15\}\) .*/\1/p'
查使用内存最多的10个进程
ps
-aux |
sort
-k4nr |
head
-n 10
查使用CPU最多的10个进程
ps
-aux |
sort
-k3nr |
head
-n 10
# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
smmsp 3521 0.0 0.7 6556 1616 ? Ss 20:40 0:00 sendmail: Queue runner@01:00:00 f
root 3532 0.0 0.2 2428 452 ? Ss 20:40 0:00 gpm -m /dev/input/mice -t imps2
htt 3563 0.0 0.0 2956 196 ? Ss 20:41 0:00 /usr/sbin/htt -retryonerror 0
htt 3564 0.0 1.7 29460 3704 ? Sl 20:41 0:00 htt_server -nodaemon
root 3574 0.0 0.4 5236 992 ? Ss 20:41 0:00 crond
xfs 3617 0.0 1.3 13572 2804 ? Ss 20:41 0:00 xfs -droppriv -daemon
root 3627 0.0 0.2 3448 552 ? SNs 20:41 0:00 anacron -s
root 3636 0.0 0.1 2304 420 ? Ss 20:41 0:00 /usr/sbin/atd
dbus 3655 0.0 0.5 13840 1084 ? Ssl 20:41 0:00 dbus-daemon-1 --system