Top

From Linuxintro
Revision as of 09:28, 14 January 2010 by imported>ThorstenStaerk (→‎normalize to 100%)

Overview

The command top shows you the top CPU consuming processes, for example like this:

top - 11:21:16 up 1 day,  2:04,  9 users,  load average: 0.99, 0.71, 0.43
Tasks: 269 total,   1 running, 268 sleeping,   0 stopped,   0 zombie
Cpu(s):  7.5%us,  1.7%sy,  0.0%ni, 90.7%id,  0.2%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   4050980k total,  3889816k used,   161164k free,   178940k buffers
Swap:  9999992k total,       68k used,  9999924k free,  2263740k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
  688 staerk    20   0  177m  54m  15m S   36  1.4  18:49.46 npviewer.bin
 7968 root      20   0 1005m 764m 740m S    5 19.3  36:06.35 vmware-vmx
32093 staerk    20   0 99.4m  78m 7132 S    2  2.0   4:29.59 nxagent
 2470 root      20   0 16944 1412  940 R    1  0.0   0:00.06 top
31336 root      20   0  180m  21m  14m S    1  0.5   0:07.36 xchat
31013 root      20   0  291m  73m 4984 S    0  1.9   2:28.11 Xorg
32318 staerk    27   7  356m  27m  10m S    0  0.7   0:02.12 beagled
    1 root      20   0  1064  384  324 S    0  0.0   0:01.30 init
    2 root      15  -5     0    0    0 S    0  0.0   0:00.02 kthreadd
    3 root      RT  -5     0    0    0 S    0  0.0   0:00.06 migration/0
    4 root      15  -5     0    0    0 S    0  0.0   0:01.22 ksoftirqd/0
    5 root      RT  -5     0    0    0 S    0  0.0   0:00.14 migration/1
    6 root      15  -5     0    0    0 S    0  0.0   0:00.66 ksoftirqd/1

By default, the display changes every second.

quit top

You can quit top by pressing q.

sort

You can sort by memory consumption by pressing M.

multi-processor-view

You can show all logical processor (and switch back to the aggregated view) by pressing 1. Then, the header looks like this:

Cpu0  :  7.5%us, 41.2%sy,  0.0%ni, 38.8%id, 12.0%wa,  0.0%hi,  0.4%si,  0.0%st
Cpu1  :  6.0%us, 35.9%sy,  0.0%ni, 51.0%id,  7.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu2  :  5.6%us, 38.3%sy,  0.0%ni, 24.3%id, 31.2%wa,  0.0%hi,  0.6%si,  0.0%st
Cpu3  :  7.6%us, 39.3%sy,  0.0%ni, 14.8%id, 37.6%wa,  0.1%hi,  0.6%si,  0.0%st

normalize to 100%

You can normalize the CPU load to 100% by pressing Shift-i. This is useful if you have more than one logical CPU.

redirect output to a file

top -b -n 1 > top.txt

See also