top gives a continuously updated, full-screen view of the running processes on a system, sorted by CPU usage by default. It also summarises system-wide metrics at the top: uptime, load averages, number of users, tasks, CPU usage per state, memory, and swap. Pressing keys interactively changes the sort, filters processes, kills them, and renices them.
Useful interactive keys: P sorts by CPU, M by memory, T by time, k kills a process, r renices one, u filters by user, c toggles full command line, H toggles threads, 1 shows per-CPU stats, and q quits.
The classic top on Linux is provided by procps-ng and reads from /proc. It is ubiquitous and works on any Linux box (and nearly any Unix), which is why it remains the default for quick interactive process inspection. For a friendlier interface with colour, mouse support, and better navigation, htop is the go-to replacement. On containers and tiny images that have neither, ps and /proc direct reads do the job.
Related terms: htop, ps, Process, Load Average
Discussed in:
- Chapter 10: Processes and Job Control — Looking at Processes
Also defined in: Textbook of Linux