Back to course

64. Interactive Process Monitoring: `top` and `htop`

Linux Basics: From Zero to CLI Hero

Real-Time System Status

While ps gives a snapshot, top and htop provide dynamic, continuously updating views of system resource usage.

top (Table of Processes)

top shows the processes that are consuming the most CPU and memory, updating every few seconds.

Key top Interactions:

  • M: Sorts the process list by Memory usage.
  • P: Sorts the process list by CPU usage (default).
  • k: Kill a process (prompts for PID).
  • q: Quit.

htop (Improved top)

htop is an interactive, enhanced version of top (often not installed by default, you may need sudo apt install htop).

Advantages of htop:

  • Color-coded CPU and memory meters.
  • Scrollable vertically and horizontally.
  • Easier to kill processes using function keys (F9).
  • Shows processes in a hierarchy (tree view, F5).

Action: Install htop (sudo apt install htop) and run it to compare it with top.