Linux下的常用指令

CPU相关

# 查看CPU物理核心
cat /proc/cpuinfo | grep 'physical id' | sort -u | wc -l
# 查看CPU核心总数
cat /proc/cpuinfo | grep 'cpu cores' | wc -l
# 查看逻辑CPU
cat /proc/cpuinfo | grep 'processor' | wc -l
# 查看指定进程的线程情况
ps -mp 8463 -o THREAD,tid,time
# 查看进程的线程CPU占用
top -H -p 32286

内存相关

# 释放页面缓存
echo 1 > /proc/sys/vm/drop_caches
# 释放目录缓存、文件缓存
echo 2 > /proc/sys/vm/drop_caches
# 释放页面缓存、目录缓存、文件缓存
echo 3 > /proc/sys/vm/drop_caches

# 查看是否开启内存大页
cat /proc/meminfo | grep 'Huge'

# 关闭透明大页
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag
echo 'echo never > /sys/kernel/mm/transparent_hugepage/defrag' >> /etc/rc.d/rc.local
echo 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' >> /etc/rc.d/rc.local

Docker相关

# 清理无用的容器
docker system prune

Author: bugwz
Link: https://bugwz.com/2018/01/01/commands-linux/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.