How to Sort by CPU in htop?

This article provides a quick, step-by-step guide on how to sort running processes by CPU utilization using the htop interactive process viewer in Linux. You will learn the standard keyboard shortcuts, how to navigate the interactive menu, and how to reverse the sorting order to effectively monitor system performance.

Step-by-Step Sorting in htop

htop is a powerful, interactive text-mode process viewer for Unix systems that improves upon the classic top command. By default, htop usually sorts processes by CPU usage automatically, but if your configuration has changed, you can easily sort by CPU using two different methods.

Method 1: Using Keyboard Shortcuts (Fastest)

The quickest way to sort by CPU utilization is by using a direct keyboard shortcut while htop is running.

Method 2: Using the Interactive Setup Menu

If you prefer a visual menu or want to explore other sorting criteria, you can use the built-in configuration menu.

  1. Open the Setup Menu: Press F6 (or Shift + O) on your keyboard. This opens the “Sort by” menu on the left side of the screen.
  2. Select CPU%: Use the arrow keys to scroll down the list until PERCENT_CPU (or CPU%) is highlighted.
  3. Confirm the Selection: Press Enter. Your process list will instantly update to sort by CPU usage.

Reversing the Sort Order

If you want to reverse the order (e.g., to see the processes using the least amount of CPU at the top):