Top显示内容详解
执行sudo top
- Summary 部分
top - 09:11:25 up 6 days, 35 min, 2 users, load average: 0.33, 0.34, 0.21
top - 系统时间 up 运行时间,当前登录用户数量 load average:1分钟负载, 5分钟负载,15分钟负载
Tasks: 131 total, 1 running, 78 sleeping, 0 stopped, 0 zombie
Tasks:当前系统进程数,运行状态进程数,休眠状态进程数,停止状态进程数, 僵尸状态进程数
%Cpu(s): 2.7 us, 0.2 sy, 0.0 ni, 96.8 id, 0.3 wa, 0.0 hi, 0.0 si, 0.0 st
%Cpu(s): 用户空间占用CPU的百分比us, 内核空间占用CPU的百分比sy, 改变过优先级的进程占用CPU百分比ni,空闲CPU百分比id,IO等待占用CPU的百分比wa, 硬中断(Hardware IRQ)占用CPU的百分比hi, 软中断(Software IRQ)占用CPU的百分比si,虚拟机管理平台占用CPU的百分比st
KiB Mem : 4039608 total, 173672 free, 1028152 used, 2837784 buff/cache
KiB Mem : 物理内存总量 total, 空闲内存总量 free, 使用中内存总量 used, 缓存的内存量 buff/cache
KiB Swap: 2356220 total, 2279420 free, 76800 used. 2720720 avail Mem
KiB Swap: 交换区总量 total,空闲交换区总量 free, 使用的交换区总量 used, 缓冲的交换区总量 avail Mem
补充:单位转换关系
KiB = kibibyte = 1024 bytes
MiB = mebibyte = 1024 KiB = 1,048,576 bytes
GiB = gibibyte = 1024 MiB = 1,073,741,824 bytes
TiB = tebibyte = 1024 GiB = 1,099,511,627,776 bytes
PiB = pebibyte = 1024 TiB = 1,125,899,906,842,624 bytes
EiB = exbibyte = 1024 PiB = 1,152,921,504,606,846,976 bytes
2.TASK部分
补充:进程状态说明
D = uninterruptible sleep
I = idle
R = running
S = sleeping
T = stopped by job control signal
t = stopped by debugger during trace
Z = zombie
Top 命令说明
1.命令行参数
-hv|-bcEHiOSs1 -d secs -n max -u|U user -p pid -o fld -w [cols]
查看对应帮助与版本
top -h
top -v
批处理方式显示top信息,理解为滚动显示,是不是有点tail -f 的感觉。。。
top -b
覆盖排序字段 as -o +|-fieldname
top -o +%CPU
输出所有字段名称
top -O
查看对应pid进程的信息 as -pN1, N2, N3 (N1代表PID)
top -p20371,20372,20373
用户过滤模式 as -u | -U number or name (number:用户ID,name:用户名)
top -u developer
2.基础操作
h or ? 帮助
q or Ctrl+c 退出
3. 挂起与恢复操作
Ctrl+Z 挂起
reset 恢复终端设置(直接使用第三条无法恢复的情况下会先用这条指令) fg 恢复(命令行输入,前面不是退出了,对吧)
强制屏幕重绘
4.交互命令
Z,B,E,e Global: 'Z' colors; 'B' bold; 'E'/'e' summary/task memory scalel,t,m Toggle Summary: 'l' load avg; 't' task/cpu stats; 'm' memory info0,1,2,3,I Toggle: '0' zeros; '1/2/3' cpus or numa node views; 'I' Irix modef,F,X Fields: 'f'/'F' add/remove/order/sort; 'X' increase fixed-widthL,&, . Locate: 'L'/'&' find/again; Move sort column: '' left/rightR,H,V,J . Toggle: 'R' Sort; 'H' Threads; 'V' Forest view; 'J' Num justifyc,i,S,j . Toggle: 'c' Cmd name/line; 'i' Idle; 'S' Time; 'j' Str justifyx,y . Toggle highlights: 'x' sort field; 'y' running tasksz,b . Toggle: 'z' color/mono; 'b' bold/reverse (only if 'x' or 'y')u,U,o,O . Filter by: 'u'/'U' effective/any user; 'o'/'O' other criterian,#,^O . Set: 'n'/'#' max tasks displayed; Show: Ctrl+'O' other filter(s)C,... . Toggle scroll coordinates msg for: up,down,left,right,home,endk,r Manipulate tasks: 'k' kill; 'r' reniced or s Set update intervalW,Y Write configuration file 'W'; Inspect other output 'Y'q Quit