Skip to main content

Linux Tips: Using htop

Linux Performance
By Keith Edmunds17 May 2017No Comments

One of the first commands many system administrators learn is top, which shows (amongst other things) which processes are using the most CPU. top has been around for years, but the new(-ish) kid on the block is htop. Unlike top, you may need to install htop yourself.

Keyboard Shortcuts

Superficially, htop performs similarly to top, but it has more functionality:

  • F2 configures the display setup
  • F6 allows sorting by different columns
  • t will display a process tree
  • s will run strace on the highlighted process
  • l (lowercase L) will show all open files for the highlighted process (using lsof)
  • L will show the library calls for the highlighted process (using ltrace)
  • the display may be scrolled horizontally (arrow keys) and vertically (arrow keys or page up/down)
  • F1 shows more help

Some Practical Uses of htop

  • Highlighting a process and pressing the space bar will select that process and show it in a different colour. Multiple processes may be selected, making it easy to track them in the display.
  • F9 will kill all selected processes.
  • Use F6 and sort by M_SIZE to see which processes are using the most memory (physical and virtual)

As always, the man page has more detail.

Could this Linux Tip be improved? Let us know in the comments below.