What do the summary lines show?
top - 10:14:03 up 12 days, 2:41, 1 user, load average: 2.31, 1.97, 1.80 Tasks: 287 total, 2 running, 285 sleeping, 0 stopped, 0 zombie %Cpu(s): 9.8 us, 2.1 sy, 0.0 ni, 87.6 id, 0.3 wa, 0.0 hi, 0.2 si, 0.0 st MiB Mem : 64042.1 total, 2210.4 free, 19877.0 used, 42780.3 buff/cache MiB Swap: 4096.0 total, 4096.0 free, 0.0 used. 44165.1 avail Mem
- Line 1: time, uptime, users and the 1, 5 and 15 minute load averages.
- Tasks: process counts by state; a growing zombie count points to a parent not reaping children.
- %Cpu: user, system, nice, idle, I/O wait, hardware and software interrupts, and steal, which is zero on bare metal.
- Mem and Swap: totals in MiB; "avail Mem" is the number to watch, not "free".
Reading load against thread count is covered in Check CPU usage and load, and memory figures in Check memory usage.
What do the process columns mean?
| Column | Meaning |
|---|---|
PR / NI | Kernel priority and nice value |
VIRT | Mapped address space, mostly irrelevant |
RES | Memory actually in RAM |
SHR | Part of RES that is shared |
S | State: R running, S sleeping, D waiting on I/O, Z zombie |
%CPU | Share of one CPU; can exceed 100 for multi-threaded processes |
TIME+ | Total CPU time consumed |
A process at 800 percent CPU on a 16-thread machine is using eight threads' worth, half the box. Press Shift+I to switch to "Irix mode off", where percentages are divided by the CPU count and never exceed 100.
Which keys should I know?
| Key | Action |
|---|---|
P / M / T | Sort by CPU, memory or CPU time |
1 | Show each CPU separately |
2 | Show each NUMA node on dual-socket machines |
H | Show threads instead of processes |
c | Show full command lines |
u | Filter by user |
o | Add a filter, such as COMMAND=php or %CPU>5 |
k | Send a signal to a process |
f | Choose and order columns |
W | Save the current layout to the config file |
The 2 key is handy on dual-socket models such as D5: it shows whether one socket's cores are busy while the other's idle. H reveals which thread of a Java or database process burns CPU, and its thread id can be matched to a stack dump.
How do I keep my preferred layout?
Arrange columns and sorting, then press W. The layout is saved to ~/.config/procps/toprc and used every time that user starts top. Teams often copy one file to every admin account for a common view.
How do I use top in scripts or logs?
Batch mode prints plain text and exits after a set number of updates:
top -b -n 1 -o %MEM | head -20 > /var/tmp/top-$(date +%H%M).txt top -b -d 5 -n 12 -p "$(pgrep -d, -f 'php-fpm: pool shop')" >> /var/log/fpm-watch.log
The first command snapshots the top memory users. The second watches the PHP-FPM workers of one pool every five seconds for a minute. Wrapping the first in a cron job during an incident gives you a cheap timeline.
Is there anything better than top?
htop adds color, mouse support, tree views and easy scrolling; btop adds graphs for CPU, memory, disks and network. Both install from standard repositories. atop records history to disk, so you can replay what happened during last night's spike. top remains worth knowing because it is always present, even on a minimal image or a rescue session.
How do I stop a process from top?
Press k, type the PID, and accept the default signal 15 (TERM). Only use 9 (KILL) if the process ignores TERM. Signals and safer ways to stop services are explained in Kill a process.
Keep Reading
Check CPU usage and load
Read load averages against your thread count, split CPU time by type with mpstat and vmstat, find the busy process and keep history with sar.
OpenKill a process
Stop processes the right way: find them, send TERM before KILL, use systemctl for services, and handle zombies and stuck D-state tasks.
OpenCheck memory usage
Read free, /proc/meminfo, vmstat and per-process numbers correctly, and tell real memory pressure apart from a healthy page cache.
OpenNUMA and dual-socket servers
Why two processors in one box share memory unevenly, and when a dual-socket machine beats a single big chip.
OpenFAQ
Quick Answers
Press M, or start it with top -o %MEM.
top counts one full CPU as 100 percent, so a multi-threaded process can exceed it. Shift+I switches to percentages of the whole machine.
Press 1 to toggle per-CPU lines; press 2 for per-NUMA-node lines.
Press W. The layout is stored in ~/.config/procps/toprc.
Yes. top -b -n 1 prints one snapshot as plain text for scripts and logs.