top shows running processes and keeps refreshing. Learn how to read the screen, how to get out, and how `-b` makes it usable from a script, by running the commands in a real terminal in your browser.
Updated: 2026-09-07
top [options]
It lists running processes, heaviest first, and keeps refreshing.
$ top
The screen switches to a process list and the numbers keep updating.
Press q to get back (Ctrl+C also works).
The top five lines summarise the machine; below them is the process list.
| Line | What to read |
|---|---|
top - ... | Current time, uptime, load average |
Tasks: | How many processes, and in which states (running / sleeping / zombie) |
%Cpu(s): | CPU breakdown; id is how much is idle |
MiB Mem : | Memory; avail Mem on the right is what is really available |
MiB Swap: | Swap; growing used means memory pressure |
The list is sorted by %CPU, so the top row is whatever is heavy right now.
Load average covers 1, 5 and 15 minutes. Read it against the core count: staying above that means work is queueing up.
-b (batch) with -n 1 prints a single round as ordinary output instead of taking over the screen.
$ top -b -n 1
top - 17:33:40 up 10:30:45, 2 users, load average: 0.12, 0.15, 0.10
Tasks: 12 total, 2 running, 10 sleeping, 0 stopped, 0 zombie
%Cpu(s): 3.0 us, 1.3 sy, 0.0 ni, 95.4 id, 0.3 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 7948.0 total, 1843.0 free, 3277.0 used, 2828.0 buff/cache
MiB Swap: 2048.0 total, 1920.0 free, 128.0 used. 4200.0 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
3456 user 20 0 446.1m 85.6m 59.9m R 98.5 4.2 2:34:56 python3
2345 user 20 0 11.0m 1.2m 987k R 1.5 0.0 0:00.01 top
2847 user 20 0 337.6m 55.5m 38.8m S 1.2 1.5 1:23 node
123 root 20 0 117.5m 9.6m 6.8m S 0.3 0.2 0:01 systemd-j
1234 user 20 0 22.9m 3.4m 2.4m S 0.2 0.1 0:00 zsh
789 user 20 0 44.6m 5.3m 3.7m S 0.1 0.1 0:00 sshd
1 root 20 0 165.3m 12.8m 9.0m S 0.0 0.1 0:02 systemd
2 root 20 0 0k 0k 0k S 0.0 0.0 0:00 kthreadd
456 root 20 0 44.6m 5.3m 3.7m S 0.0 0.1 0:00 sshd
5678 root 20 0 12.1m 2.3m 1.6m S 0.0 0.0 0:00 crond
301 root 20 0 5.5m 1.2m 863k S 0.0 0.0 0:00 networking
201 systemd- 20 0 24.0m 6.6m 4.6m S 0.0 0.1 0:01 systemd-r
python3 is using 98.5 percent of the CPU.
This is the form to use when you want to keep the evidence or append it to a log.
ps can produce the same order.
$ ps aux | sort -k3 -nr | head -3
user 3456 98.5 4.2 456789 87654 pts/0 R 09:15 154:56 python3 backup_sync.py
user 2847 1.2 1.5 345678 56789 pts/0 S 10:35 1:23 node server.js
root 123 0.3 0.2 120344 9876 ? Ss 00:01 0:01 /lib/systemd/systemd-journald
-k3 sorts on the third column, %CPU, and -nr sorts numerically, largest first.
top to watch, ps to pass along.
top is the first screen you open when someone says the server is slow.
| Situation | What to type |
|---|---|
| See what is heavy | top |
| Keep a record of it | top -b -n 1 >> load.log |
| Just the three heaviest | ps aux | sort -k3 -nr | head -3 |
| Check memory headroom | free -h |
| Stop the culprit | kill <PID> |
Find the PID with top, stop it with kill.
The two go together.
q is the way out.
Ctrl+C ends it as well, but q is the proper key.
%CPU is an instant reading.
A brief spike can be perfectly normal.
Read it together with TIME+, the total CPU time that process has used, to tell a spike from a long burn.
Read avail Mem, not free.
A small "free" number is fine when buff/cache is large, because that memory is handed back on demand.
It is a screen, not a tool for scripts.
For automated records use top -b -n 1, or ps.
webterm.appthis site
Advanced Terminal Commands
Learn commands for specific situations
learn.webterm.appa separate site

Commands stick when they show up in a real sequence of work, not one at a time. There is a course that builds them up in order.
See the course