Linux top Command Explained: Load Average, CPU States, Memory and Useful Keys

Cyber Security3 min read
Linux top command output with load average and process list
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
LineWhat it tells you
Uptime and usersHow long since boot and how many users are logged in
Load averageAverage number of processes running or waiting, over 1, 5 and 15 minutes
TasksTotal processes and how many are running, sleeping, stopped or zombie
%Cpu(s)How CPU time is split between states (below)
MemPhysical memory: total, free, used and buffer/cache
SwapSwap 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

FieldMeaning
usUser processes (applications)
syKernel (system) work
niLow-priority (niced) user processes
idIdle
waWaiting for disk or network I/O; high values point to storage bottlenecks
hi, siHardware and software interrupts
stTime stolen by the hypervisor (virtual machines)

Process columns

ColumnMeaning
PIDProcess ID
USEROwner
PR, NIPriority and nice value
VIRT, RES, SHRVirtual, resident and shared memory
SState: R running, S sleeping, D waiting for I/O, Z zombie
%CPU, %MEMCPU and memory share
TIME+Total CPU time used
COMMANDProcess name

Keys you will use most

KeyAction
PSort by CPU (default)
MSort by memory
1Show each CPU core separately
cShow full command lines
uShow only one user’s processes
kKill a process by PID
rRenice (change priority)
fChoose and order columns
WSave the current layout as default
qQuit

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 aux and its logs.
  • High wa: the disk is the bottleneck; check with iostat or iotop.
  • 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.

Written by

Taifun Mamedov

Founder and instructor at Ocsaly Academy.

Courses by Taifun Mamedov

Share this article