Start top
top
The screen refreshes every few seconds. Press q to quit and h for help. The first five lines are the summary; below them is the process list, sorted by CPU use.
Read the Header Lines
The summary looks like this, with your own numbers:
top - 10:15:02 up 12 days, 3:04, 1 user, load average: 0.42, 0.37, 0.30
Tasks: 118 total, 1 running, 117 sleeping, 0 stopped, 0 zombie
%Cpu(s): 3.1 us, 1.0 sy, 0.0 ni, 95.6 id, 0.2 wa, 0.0 hi, 0.1 si, 0.0 st
MiB Mem : 3916.2 total, 412.5 free, 1210.8 used, 2292.9 buff/cache
MiB Swap: 2048.0 total, 2048.0 free, 0.0 used. 2705.4 avail Mem
- Line 1: the time, uptime, logged-in users, and the 1, 5, and 15 minute load averages. See what load average means.
- Tasks: processes by state. A growing zombie count points to a program that does not clean up its child processes.
- %Cpu(s): how CPU time is split, explained below.
- Mem and Swap: the same figures as
free.avail Memis what programs can still get; a low free value is normal.
The CPU Fields
| Field | Time spent on |
|---|---|
us | User programs |
sy | The kernel |
ni | Programs with lowered priority |
id | Nothing (idle) |
wa | Waiting for disk I/O |
hi, si | Hardware and software interrupts |
st | Stolen by the hypervisor |
High us or sy means the server is busy computing. High wa means it is waiting for the disk; see how to check disk I/O. On a virtual server, st is explained in CPU steal time. Press 1 to see each CPU on its own line.
The Process Columns
PID is the process ID, USER its owner, PR and NI its priority and nice value. VIRT is all memory the process has mapped, RES the part held in RAM, and SHR the shared part of RES. S is the state: R running, S sleeping, D waiting on I/O, Z zombie. TIME+ is the CPU time used since the process started.
Keys for Sorting and Viewing
| Key | What it does |
|---|---|
P | Sort by CPU |
M | Sort by memory |
T | Sort by CPU time |
1 | One line per CPU |
c | Full command line |
u | Show one user |
k | Send a signal to a PID |
The sort keys are capital letters. k asks for the PID and then the signal, with 15 (SIGTERM) as the default; keep that default. The safe order is in how to kill a process.
Useful Options
top -u www-data
top -p 1234
top -d 5
top -o %MEM
These show only one user's processes, watch one PID, refresh every five seconds, and sort by memory from the start.
Save a Snapshot with Batch Mode
Batch mode prints plain text instead of the live screen, which is what you need in a script, a cron job, or a support ticket:
top -b -n 1 | head -n 20
top -b -n 1 -o %MEM > top-$(date +%F-%H%M).txt
-b turns on batch mode and -n 1 stops after one refresh. For a friendlier interactive view with mouse support, see htop; for history over hours, atop records snapshots to disk.