How to Search for a Process by Name or PID in htop?
The htop interactive process viewer is a powerful
alternative to the traditional top command in Linux,
offering a real-time, color-coded overview of system resources. While
navigating a massive list of running processes can be overwhelming,
htop provides dedicated, efficient built-in shortcuts to
instantly filter or locate specific processes by their name or Process
ID (PID). This guide will walk you through using the search and filter
functions to pinpoint exactly what you are looking for in seconds.
Searching for a Process by Name
If you want to find a process but keep the rest of the process list visible, you can use the native search function. This highlights the matching results as you type.
- Step 1: Open
htopin your terminal. - Step 2: Press the
F3key (or the/key) to open the search prompt at the bottom of the screen. - Step 3: Type the name of the process you want to
find (for example,
nginxorpython). - Step 4: The cursor will automatically jump to the
first matching entry. To cycle through next matches, press
F3again.
Filtering the Process List by Name
When dealing with hundreds of active threads, it is often easier to hide everything else and only display the processes you care about. The filtering tool is perfect for this scenario.
- Step 1: Press the
F4key (or the\key) to activate the filter bar. - Step 2: Type the process name or keyword.
- Step 3: The screen will instantly update, hiding all unrelated processes and leaving only the ones that match your query.
- Step 4: To clear the filter and return to the full
list, press
F4, clear the text with Backspace, and hit Enter.
Finding a Process by PID
While typing a PID into the search (F3) or filter
(F4) menus will successfully locate the numbers,
htop also allows you to sort the entire process list by PID
for easier navigation.
- Step 1: Click on the PID column
header at the top of the process list using your mouse, or use the
F6key to open the “Sort by” menu. - Step 2: Select PID from the menu and press Enter to sort the list numerically.
- Step 3: Use the
F3search function to type the exact PID number, which will instantly highlight the specific process on your sorted list.