Beginner · 6 min · practise every command in the built-in terminal

top — Real-time Process Monitor

top shows a live view of running processes and system resources.

Run top

top

Interactive keys inside top

KeyAction
qQuit
kKill a process (enter PID)
hHelp
MSort by memory
PSort by CPU
uFilter by user
1Show per-CPU stats
SpaceRefresh now

top header

top - 10:30:00 up 5 days, 2:30,  2 users,  load average: 0.15, 0.10, 0.05
Tasks: 120 total,   1 running, 119 sleeping
%Cpu(s):  2.0 us,  1.0 sy,  0.0 ni, 96.0 id
MiB Mem :  7876.5 total,  2000.0 free,  3000.0 used
  • load average: 1, 5, 15 minute averages (1.0 = 100% one core)
  • us: user space CPU
  • sy: kernel/system CPU
  • id: idle

Non-interactive

top -b -n 1 | head -20     # One snapshot, pipe-able

htop

htop is top but better — color, mouse support, easier killing.

htop

Practice tasks

  1. Run top in batch mode for one iteration
  2. Run top normally to see the live process view
  3. Pipe a single top snapshot into head to see just the first lines

Commands in this lesson

Processes