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.
- Press
P(Uppercase P): PressingShift + Pinstantly sorts all running processes by their current CPU usage in descending order (highest consumption at the top).
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.
- Open the Setup Menu: Press
F6(orShift + O) on your keyboard. This opens the “Sort by” menu on the left side of the screen. - Select CPU%: Use the arrow keys to scroll down the
list until
PERCENT_CPU(orCPU%) is highlighted. - 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):
- Press
I(Uppercase I): PressingShift + Iinverts the current sorting order. Pressing it again will flip it back to descending order.