Live monitoring in Linux: top and htop
Updated November 1, 2026
top and htop show a live list of processes, sorted by their CPU or memory load.
Common cases
top # a live list, q to quit
htop # friendlier: colour, scrolling, mouse
# inside top:
# P sort by CPU
# M sort by memory
# k send a signal to a process
ps aux --sort=-%cpu # a snapshot: top by CPU, no live modeSample output
$ top -b -n 1
top - 03:49:38 up 5 days, 1:20, 0 user, load average: 2.76, 2.08, 1.15
Tasks: 4 total, 2 running, 2 sleeping, 0 stopped, 0 zombie
%Cpu(s): 9.5 us, 0.0 sy, 0.0 ni, 90.5 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 12017.3 total, 9584.6 free, 1317.7 used, 1498.7 buff/cache
MiB Swap: 13041.3 total, 13041.3 free, 0.0 used. 10699.6 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
7 student 20 0 7296 3020 2504 R 100.0 0.0 0:01.21 md5sum
1 student 20 0 4472 3272 2980 S 0.0 0.0 0:00.01 bash
8 student 20 0 2708 1700 1596 S 0.0 0.0 0:00.00 sleep
10 student 20 0 9064 5016 2888 R 0.0 0.0 0:00.00 topHow it works: a snapshot versus live mode
psgives one snapshot and exits, whiletopandhtoprefresh every couple of seconds. That is what you need to catch what is loading the system. The top rows show a summary: the load average, CPU usage and memory. Below them are the processes, the greediest on top by default.htopis nicer thantop: you can scroll the list, click a process and kill it, and per-core usage bars sit at the top. Ifhtopis not installed,topis always there.
Common mistakes
Inside a container top shows the memory and load of the whole machine, not your limits. A run capped at 256 MB still prints MiB Mem : 12017.3 total, and load average is the host's too. Limits live in cgroups while top reads /proc/meminfo. In the sandbox read the process rows, not the summary at the top.
%CPU is measured against one core, so a number above 100 is normal, not a glitch. A process with four busy threads on a ten-core machine showed 410.0: it takes 4.1 cores. The %Cpu(s) line works differently, it folds all cores into 100, and at that same moment it read 40.2 us.
VIRT is not used memory, it is the size of the address space. A process that mapped 2 GB and wrote one page into it shows VIRT 2111788 next to RES 8756, so it holds about 9 MB. Read RES for the memory actually taken from the system and ignore VIRT.
In the book
This topic is covered in full in the chapter Monitoring and bottlenecks.
See also
Viewing processes, Memory: free, Load average, The vmstat command.
Try it
Open the sandbox: a real throwaway Linux terminal in your browser. Run the commands above by hand - the container is deleted when you leave.