How to Filter htop by Current Terminal Session
The htop command-line utility is a powerful, interactive
process viewer for Linux, but its default view displays every running
process on the system, which can be overwhelming. This article provides
a quick overview of how to isolate and display only the processes
associated with your current terminal session using standard Linux
commands and htop’s built-in filtering capabilities. By
targeting your specific Process Group ID (PGID) or Terminal Device
(TTY), you can cut through the noise and monitor exactly what your
current shell is running.
Step 1: Identify Your Current Terminal Device
To filter processes by your current session, you first need to know
the name of the terminal device you are using. You can find this
instantly by running the tty command in your terminal:
ttyThis will output something like /dev/pts/2. The
pts/2 part represents your specific terminal session.
Step 2: Launch htop and Filter by TTY
Once you know your terminal device, you can start htop
and use its interactive filtering feature to isolate your processes.
- Open
htopby typinghtopin your terminal. - Press the F4 key (or
\on some configurations) to open the Filter prompt at the bottom of the screen. - Type the specific identifier of your terminal (for example,
pts/2).
As you type, htop will dynamically hide all processes
that do not match the text, leaving only the commands running inside
that specific terminal window.
Alternative Method: Filter by User Processes
If your goal is simply to clear away system background noise rather
than isolating a single window, you can restrict htop to
show only processes owned by your specific user account.
- While inside
htop, press the F3 key to open the user selection menu. - Use the arrow keys to scroll to your username and press Enter.
Alternatively, you can launch htop already filtered to
your user directly from the command line:
htop -u $USER