1. 使用 top 命令
top 命令实时显示系统资源占用情况,包括 CPU、内存等。
top
-
CPU 占用:按
P键按 CPU 使用率排序。 
-
内存占用:按
M键按内存使用率排序。 -
退出:按
q键。
2. 使用 htop 命令
htop 是 top 的增强版,界面更友好。
htop
-
安装:如果未安装,可通过
sudo apt-get install htop(Debian/Ubuntu)或sudo yum install htop(CentOS/RHEL)安装。
3. 使用 ps 命令
ps 命令显示当前进程状态。
ps aux
-
按 CPU 排序:
ps aux --sort=-%cpu -
按内存排序:
ps aux --sort=-%mem
4. 使用 vmstat 命令
vmstat 提供系统整体性能概览。
vmstat 1
-
1 表示每秒刷新一次。
5. 使用 netstat 命令
netstat 查看网络连接和端口占用。
netstat -tunlp
6. 使用 lsof 命令
lsof 列出打开的文件及对应进程。
lsof -i :端口号
7. 使用 systemctl 命令
systemctl 管理系统服务。
systemctl list-units --type=service
8. 使用 nmon 工具
nmon 提供全面的系统性能监控。
nmon
-
安装:通过
sudo apt-get install nmon或sudo yum install nmon安装。
9. 使用 glances 工具
glances 提供全面的系统监控。
glances
-
安装:通过
sudo apt-get install glances或sudo yum install glances安装。
10. 使用 sar 命令
sar 收集和报告系统活动。
sar -u 1 5
-
安装:通过
sudo apt-get install sysstat或sudo yum install sysstat安装。
总结
-
实时监控:
top、htop、glances -
进程查看:
ps、lsof -
网络监控:
netstat -
服务管理:
systemctl -
综合工具:
nmon、sar