Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

top

Watch the processes live, sorted by CPU, with load, CPU and memory totals — and kill or renice from it.

Niveau
RHCSA-examen
Groep
Processen en jobs
Root nodig
Nee
Pakket
procps-ng

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

Wat het doet

The top part shows uptime and load average, the number of tasks per state, CPU use (us user, sy system, ni niced, id idle, wa waiting for I/O, st stolen by the hypervisor) and memory and swap. Below is the process list, refreshed every 3 seconds.

Keys work while it runs: k kill, r renice, M sort by memory, P by CPU, 1 each CPU, q quit. With -b it writes plain text for logs and scripts.

Zo schrijf je het

top [OPTION]...

Belangrijkste delen

k
Kill: send a signal to a PID.
r
Renice a PID.
P / M / T / N
Sort by CPU / memory / time / PID.
1
Show every CPU.
c
Show the full command line.
u
Show only one user.
f
Choose and sort columns.
H
Show threads.
V
Forest (tree) view.
E / e
Change memory units (summary / list).
W
Save the settings in ~/.config/procps/toprc.
h
Help.
q
Quit.

Opties 19

Meest gebruikt

-b, --batch
Batch mode: plain text output (for logs and pipes).
-n, --iterations NUMBER
Stop after NUMBER updates.
-d, --delay SECONDS
Seconds between updates.
-p, --pid PIDLIST
Only these PIDs.
-u, --filter-only-euser USER
Only this effective user.
-U, --filter-any-user USER
Any user ID match (real, effective, saved, file).
-o, --sort-override FIELD
Sort by this field, like -o %MEM.
-H, --threads-show
Show threads.
-c, --cmdline-toggle
Start with full command lines.
-i, --idle-toggle
Hide idle processes.
-S, --accum-time-toggle
Cumulative time (with dead children).
-E, --scale-summary-mem k|m|g|t|p|e
Units in the summary.
-e, --scale-task-mem k|m|g|t|p
Units in the list.
-O, --list-fields
List the field names.
-s, --secure-mode
Secure mode (no kill or renice).
-w, --width [COLUMNS]
Output width in batch mode.
-1, --single-cpu-toggle
Start with each CPU shown (or one line).
-h, --help
Show help.
-V, --version
Show the version.

Voorbeelden 10

$ als gewone gebruiker# als root (of met sudo)

  1. 1Start top

    top
    top - 10:52:01 up  2:54,  2 users,  load average: 0.15, 0.10, 0.09
    Tasks: 182 total,   1 running, 181 sleeping,   0 stopped,   0 zombie
    %Cpu(s):  1.2 us,  0.5 sy,  0.0 ni, 98.1 id,  0.2 wa,  0.0 hi,  0.0 si,  0.0 st
    MiB Mem :   3654.2 total,   2201.7 free,    812.4 used,    891.3 buff/cache

    Press q to leave.

  2. 2Sort by memory

    top -o %MEM

    Or press M inside top.

  3. 3Only one user

    top -u apache

    Watch the web server processes.

  4. 4One process and its threads

    top -H -p $(pidof chronyd)

    Which thread uses the CPU.

  5. 5Save one snapshot to a file

    top -b -n 1 > /tmp/top-$(date +%H%M).txt

    Evidence for a slow-server ticket.

  6. 6Log every 10 seconds for one minute

    top -b -d 10 -n 6 | grep -A 8 '^top' > /tmp/top.log

    A short performance log.

  7. 7Kill from top

    top

    Press k, type the PID, press Enter (15) or type 9.

  8. 8Read the CPU line

    top -b -n 1 | grep Cpu

    High wa = slow disk; high st = the hypervisor is overloaded; high sy = kernel work.

  9. 9Find a crypto miner (security)

    top -b -n 1 -o %CPU | head -12

    An unknown process at 100% CPU, often from /tmp or a strange user.

  10. 10Secure mode for a shared screen

    top -s

    Nobody can kill from this top.

Let op

  • Load average counts waiting processes, also those waiting for disk. High load with low CPU use often means slow storage or NFS.

Bestanden

~/.config/procps/toprc
Saved settings (W key).

Exitcodes

0 :: Done. 1 :: Error.

Volledige handleiding

Deze pagina legt het commando uit in eenvoudige woorden. De originele handleiding heeft elk detail.

In je terminal: man top