Linux:top命令

来自WHY42
top - 15:51:18 up 163 days, 21:16,  3 users,  load average: 0.08, 0.03, 0.01
Tasks:  95 total,   2 running,  93 sleeping,   0 stopped,   0 zombie
%Cpu(s):  2.7 us,  0.0 sy,  0.0 ni, 96.7 id,  0.7 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  1023916 total,   533244 free,   100748 used,   389924 buff/cache
KiB Swap:        0 total,        0 free,        0 used.   739768 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND
 3829 www-data  20   0  135316  37080  26336 S  2.3  3.6   0:01.19 apache2
    1 root      20   0   23980   3880   2628 S  0.0  0.4   0:49.86 systemd
    2 root      20   0       0      0      0 S  0.0  0.0   0:00.01 kthreadd
    3 root      20   0       0      0      0 S  0.0  0.0   0:06.31 ksoftirqd/0
    5 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kworker/0:0H
    7 root      20   0       0      0      0 S  0.0  0.0   0:24.80 rcu_sched
  • PR:优先级
  • NI:nice值,负值为高优先级
  • VIRT:进程虚拟内存总量(Kb)=SWAP + RES
  • SHR: 共享内存大小

top模式下一些命令:

Help for Interactive Commands - procps-ng version 3.3.10
Window 1:Def: Cumulative mode Off.  System: Delay 3.0 secs; Secure mode Off.

  Z,B,E,e   Global: 'Z' colors; 'B' bold; 'E'/'e' summary/task memory scale
  l,t,m     Toggle Summary: 'l' load avg; 't' task/cpu stats; 'm' memory info
  0,1,2,3,I Toggle: '0' zeros; '1/2/3' cpus or numa node views; 'I' Irix mode
  f,F,X     Fields: 'f'/'F' add/remove/order/sort; 'X' increase fixed-width

  L,&,<,> . Locate: 'L'/'&' find/again; Move sort column: '<'/'>' left/right
  R,H,V,J . Toggle: 'R' Sort; 'H' Threads; 'V' Forest view; 'J' Num justify
  c,i,S,j . Toggle: 'c' Cmd name/line; 'i' Idle; 'S' Time; 'j' Str justify
  x,y     . Toggle highlights: 'x' sort field; 'y' running tasks
  z,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 criteria
  n,#,^O  . Set: 'n'/'#' max tasks displayed; Show: Ctrl+'O' other filter(s)
  C,...   . Toggle scroll coordinates msg for: up,down,left,right,home,end

  k,r       Manipulate tasks: 'k' kill; 'r' renice
  d or s    Set update interval
  W,Y       Write configuration file 'W'; Inspect other output 'Y'
  q         Quit
          ( commands shown with '.' require a visible task display window )