Commands.page Logo

How to Filter htop Processes by User on Ubuntu

Managing system resources effectively requires visibility into running processes. The htop utility provides an interactive view of system activity, but the default display shows all processes running on the system. This guide explains how to filter htop output to display only processes owned by a specific user on Ubuntu, allowing for quicker diagnostics and resource monitoring without the clutter of unrelated system tasks.

Install htop

If htop is not already installed on your Ubuntu system, you must install it before proceeding. Open your terminal and run the following command to install the package using the Apt package manager:

sudo apt update
sudo apt install htop

Filter Processes Using the Command Line

The most reliable method to view processes for a specific user is to launch htop with the -u flag. This tells the program to restrict the view to processes owned by the specified username immediately upon startup. Replace username with the actual account name you wish to monitor:

htop -u username

For example, to see only processes owned by the user john, you would run htop -u john. This method ensures that only relevant processes are loaded into the view, reducing resource overhead and simplifying the display.

Filter Interactively Within htop

If you already have htop running, you can apply a filter without restarting the application. Press the F4 key on your keyboard to activate the filter bar at the top of the screen. Type the username you want to isolate. While this filters based on text matching across the visible columns, it effectively hides processes that do not display the username in the user column. Press F4 again to clear the filter and return to the full process list.

Verify User Ownership

To confirm you are viewing the correct processes, look at the USER column on the left side of the htop interface. Every row displayed should list the specific username you targeted. If you see other usernames, clear the filter using F4 and relaunch htop using the -u command line flag for a strict ownership filter.