On this page
The top command shows a live, updating view of what a Linux system is doing: how busy the CPUs are, how much memory is used, and which processes use the most resources. Where ps aux gives a snapshot, top keeps refreshing (every 3 seconds by default), which makes it the first tool to open when a server feels slow.
The header, line by line
top - 11:42:07 up 3 days, 2 users, load average: 2.14, 1.20, 0.88
Tasks: 212 total, 2 running, 210 sleeping, 0 stopped, 0 zombie
%Cpu(s): 23.1 us, 4.2 sy, 0.0 ni, 62.4 id, 9.8 wa, 0.0 hi, 0.5 si, 0.0 st
MiB Mem : 7842.0 total, 412.3 free, 5210.6 used, 2219.1 buff/cache
MiB Swap: 2048.0 total, 1980.0 free, 68.0 used. 1310.4 avail Mem
| Line | What it tells you |
|---|---|
| Uptime and users | How long since boot and how many users are logged in |
| Load average | Average number of processes running or waiting, over 1, 5 and 15 minutes |
| Tasks | Total processes and how many are running, sleeping, stopped or zombie |
| %Cpu(s) | How CPU time is split between states (below) |
| Mem | Physical memory: total, free, used and buffer/cache |
| Swap | Swap usage and avail Mem, the best estimate of memory still available |
Load average should be compared with the number of CPU cores (nproc). On a 4-core machine, a load of 4 means fully busy; a load of 8 means processes are queuing.
CPU states
| Field | Meaning |
|---|---|
| us | User processes (applications) |
| sy | Kernel (system) work |
| ni | Low-priority (niced) user processes |
| id | Idle |
| wa | Waiting for disk or network I/O; high values point to storage bottlenecks |
| hi, si | Hardware and software interrupts |
| st | Time stolen by the hypervisor (virtual machines) |
Process columns
| Column | Meaning |
|---|---|
| PID | Process ID |
| USER | Owner |
| PR, NI | Priority and nice value |
| VIRT, RES, SHR | Virtual, resident and shared memory |
| S | State: R running, S sleeping, D waiting for I/O, Z zombie |
| %CPU, %MEM | CPU and memory share |
| TIME+ | Total CPU time used |
| COMMAND | Process name |
Keys you will use most
| Key | Action |
|---|---|
| P | Sort by CPU (default) |
| M | Sort by memory |
| 1 | Show each CPU core separately |
| c | Show full command lines |
| u | Show only one user’s processes |
| k | Kill a process by PID |
| r | Renice (change priority) |
| f | Choose and order columns |
| W | Save the current layout as default |
| q | Quit |
Useful command-line options
top -o %MEM start sorted by memory
top -u www-data only one user's processes
top -p 812,1430 watch specific PIDs
top -b -n 1 > top.txt one snapshot in batch mode, for scripts and logs
top -d 1 refresh every second
top for troubleshooting and security
- High us with one process on top: an application is busy; inspect it with
ps auxand its logs. - High wa: the disk is the bottleneck; check with
iostatoriotop. - Memory nearly gone and swap growing: a process is leaking memory; sort with M.
- Unknown process with high CPU under a service account: a classic sign of a cryptominer or other compromise; capture its details before killing it.
Related guides: execve system call explained.
Frequently asked questions
What does the top command do in Linux?
It shows a live view of system load, CPU and memory usage, and the processes using the most resources, refreshing every few seconds.
How do I sort top by memory?
Press M while top is running, or start it with top -o %MEM.
How do I exit top?
Press q.
What is a good load average?
It depends on the number of CPU cores. A load below the core count is fine; consistently above it means processes are waiting for CPU.
What is the difference between top and htop?
htop is an interactive alternative with colours, mouse support and easier sorting and filtering. top is installed everywhere by default.
Learn Linux internals
Our free Linux command line cheat sheet covers the everyday commands, and our Assembly and Shellcode Development course shows what processes, system calls and memory look like underneath.


