How to Use htop Command in Linux (Best Commands and Examples)






How to Use htop Command in Linux (Best Commands and Examples) | LinuxTeck






Still using top to check processes? htop gives you a faster, clearer, and more powerful way to monitor your system. The htop command in Linux provides an interactive method of viewing current system processes. This tool gives you a snapshot of what your system is currently doing, including the processes that are active, how much CPU time each process is using, how much memory (RAM) each process has consumed, and how busy your processor cores are. All this information is displayed in a single window in a color-coded, scrollable interface. In addition to monitoring processes, htop allows you to interact with them using simple keyboard shortcuts, such as searching for specific processes, sorting data columns, killing unresponsive tasks, and adjusting process priorities all within the same terminal session.

Whether you are just starting to learn Linux and want to understand how your RAM is being utilized, or you are a system administrator troubleshooting a slow server, htop provides the insight and tools you need.

Note:

htop is a process monitor, not a process scheduler. If you need to list processes in a scriptable, non-interactive way, consider the
ps command.
For a built-in, command-line alternative to htop, see the
top command.

Examples



Syntax - htop
htop [OPTIONS]

# Launch htop with default view
htop

# Monitor a specific user's processes
htop -u username

# Set a custom update delay (in tenths of a second)
htop -d 20

# Monitor a specific PID
htop -p 1234

♥ Quick Reference - htop Options
Flag Long Form Description
-u --user=USERNAME Show only processes belonging to the specified user
-p --pid=PID Monitor only the process(es) with the given PID(s)
-d --delay=DELAY Set the refresh interval in tenths of a second (e.g. -d 10 = 1 second)
-s --sort-key=COLUMN Start with the process list sorted by the specified column (e.g. PERCENT_CPU)
-t --tree Launch in tree view, showing parent–child process relationships
-C --no-color Run htop without colors - useful on monochrome terminals
-H --highlight-changes Highlight rows that have recently changed values
-M --no-mouse Disable mouse support (keyboard-only navigation)
-v --version Print the installed htop version and exit
-h --help Display a brief help summary and exit




#01

htop Command in Linux: How to Launch htop

You can run htop by entering it directly into the terminal with no additional parameters. This launches an interactive, full-screen process monitoring dashboard. At the top, multiple panels display key system data, including per-CPU activity bars, memory and swap usage, load average (indicating how busy the system has been over recent intervals), uptime, and the total number of active tasks-providing a complete view of your system’s status. The display refreshes automatically, with a default update interval of every 2 seconds.

bash
LinuxTeck.com
htop
Sample Output
1 [||| 12.5%] Tasks: 142, 421 thr; 2 running
2 [||||| 18.3%] Load average: 0.45 0.38 0.31
Mem[||||||||||||| 2.34G/7.68G] Uptime: 03:14:22
Swp[ 0K/2.00G]

PID USER PRI NI VIRT RES SHR S CPU% MEM% TIME+ Command
1234 root 20 0 512M 18M 5.2M S 2.3 0.2 0:04.21 /usr/sbin/sshd
2871 john 20 0 1.2G 210M 42M S 1.1 2.7 0:31.08 /usr/bin/python3
891 www-data 20 0 412M 55M 12M S 0.5 0.7 0:12.44 nginx: worker

Note:

If htop is not installed, use the package manager for your distro:
sudo apt install htop (Ubuntu/Debian),
sudo dnf install htop (Fedora/RHEL),
sudo pacman -S htop (Arch).
Once inside htop, press q to quit and return to your shell.

#02

htop Command in Linux: Sort by CPU or Memory Usage

When your computer is feeling slow, locate the largest resource-consuming application quickly. You can start htop with a sort in advance using the -s flag, or use the keyboard shortcuts P (for CPU) and M (for memory) after launching htop to view applications sorted accordingly.

bash
LinuxTeck.com
# Launch htop pre-sorted by CPU usage (highest first)
htop -s PERCENT_CPU

# Launch htop pre-sorted by memory usage
htop -s PERCENT_MEM

Sample Output - sorted by CPU%
PID USER PRI NI VIRT RES SHR S CPU% MEM% TIME+ Command
3842 john 20 0 2.1G 512M 88M R 87.3 6.5 12:04.33 /usr/bin/python3 train.py
1204 root 20 0 980M 210M 44M S 12.1 2.7 3:21.07 /usr/bin/java -jar app.jar
512 john 20 0 612M 92M 18M S 3.4 1.2 0:44.12 /usr/bin/node server.js

Tip:

While inside htop, press F6 to open the sort column picker, or click directly on any column header to toggle between ascending and descending order. Press P to jump straight to CPU sort, and M for memory sort.

#03

Search for a Running Process by Name

With so many applications running simultaneously, scrolling through them would be a waste of time. Simply click F3 (or /) to bring up a live search window that will highlight all applicable matches as you enter them.

bash
LinuxTeck.com
# Step 1 - open htop
htop

# Step 2 - press F3 or / then type the process name
# Example: searching for "nginx"
Search: nginx

Sample Output - search result highlighted
PID USER PRI NI VIRT RES SHR S CPU% MEM% TIME+ Command
891 www-data 20 0 412M 55M 12M S 0.5 0.7 0:12.44 nginx: master process
892 www-data 20 0 412M 48M 12M S 0.3 0.6 0:08.11 nginx: worker process
893 www-data 20 0 412M 47M 11M S 0.2 0.6 0:07.53 nginx: worker process

Note:

Press F3 again to jump to the next match if multiple processes share the same name. Press Esc to close the search bar and return to the full list. The search is case-insensitive by default.

#04

Kill a Process Directly from htop

Once you have selected an application from the list, select it using the arrow keys and then press F9 to bring up the available options for sending signals to this application. Choose 15 for SIGTERM to allow for the graceful shutdown of the application; or choose 9 for SIGKILL to send a "force" terminate signal. There is no reason to first look up the PID of each process individually.

bash
LinuxTeck.com
# Step 1 - open htop
htop

# Step 2 - use arrow keys to select the process
# Step 3 - press F9, select signal, press Enter
# To force-kill: select signal 9 (SIGKILL)

Sample Output - signal menu (F9)
Send signal to process 3842 "python3":

2 SIGINT Interrupt (same as Ctrl+C)
3 SIGQUIT Quit and dump core
9 SIGKILL Kill immediately (cannot be caught)
15 SIGTERM Graceful termination (default)

[ Use arrow keys to select, Enter to confirm ]

Danger - SIGKILL:

Signal 9 (SIGKILL) terminates a process instantly with no cleanup. Unsaved data will be lost and open files may be left in an inconsistent state. Always try 15 (SIGTERM) first and only escalate to SIGKILL if the process does not respond.

#05

Filter Processes by a Specific User

If you're working on multiple computers, it won't take long before the number of users creates a crowded list of processes. In addition to launching htop with the -u option to view only the processes of one user at a time, you may also use the u key within htop to browse through users and pick which ones' processes you want to display.

bash
LinuxTeck.com
# Show only processes owned by www-data
htop -u www-data

# Show only processes owned by the current logged-in user
htop -u $USER

Sample Output - filtered to www-data only
PID USER PRI NI VIRT RES SHR S CPU% MEM% TIME+ Command
891 www-data 20 0 412M 55M 12M S 0.5 0.7 0:12.44 nginx: master process
892 www-data 20 0 412M 48M 12M S 0.3 0.6 0:08.11 nginx: worker process
1021 www-data 20 0 380M 41M 10M S 0.2 0.5 0:05.33 php-fpm: pool www

Tip:

You can also filter by user interactively while inside htop - press u to open a user list and select the one you want. Press u again and choose All users to clear the filter.

#06

View Processes in Tree Mode

Tree mode shows parent–child relationships between processes, making it easy to spot which workers were forked from which parent. Launch with -t or toggle with F5 while inside htop.

bash
LinuxTeck.com
# Launch htop in tree view
htop -t

# Toggle tree view while already inside htop
# Press F5

Sample Output - tree view
PID USER CPU% MEM% Command
1 root 0.0 0.1 systemd
├─ 512 root 0.0 0.1 ├─ sshd
│ └─ 891 john 0.1 0.2 │ └─ sshd: john@pts/0
│ └─ 892 john 0.0 0.1 │ └─ bash
├─ 210 root 0.0 0.2 ├─ nginx: master process
│ ├─ 211 www-data 0.3 0.6 │ ├─ nginx: worker process
│ └─ 212 www-data 0.2 0.5 │ └─ nginx: worker process

Note:

In tree mode, killing a parent process will also terminate all its child processes. Press F5 again to switch back to the flat list view at any time.

#07

Change Process Priority (Renice) in htop

Every process has a nice value from -20 (highest priority) to 19 (lowest). Inside htop, press F7 to raise priority or F8 to lower it - no need to exit and run renice manually.

bash
LinuxTeck.com
# Step 1 - open htop
htop

# Step 2 - select a process with arrow keys
# Step 3 - press F7 to increase priority (lower nice value)
# Step 4 - press F8 to decrease priority (raise nice value)

# Alternatively, renice from the terminal directly
renice -n 10 -p 3842

Sample Output - after lowering priority of PID 3842
PID USER PRI NI VIRT RES SHR S CPU% MEM% TIME+ Command
3842 john 30 10 2.1G 512M 88M R 14.2 6.5 12:09.01 /usr/bin/python3 train.py

3842: old priority 0, new priority 10

Tip:

Only the root user can set a negative nice value (higher priority than default). Regular users can only increase the nice value - making a process slower, not faster. Use sudo htop if you need to boost a process priority.

#08

Essential htop Keyboard Shortcuts

htop is designed to be fully keyboard-driven. These are the shortcuts you will reach for most often. Press h inside htop to see the complete list.

bash
LinuxTeck.com
# Navigation
Arrow keys # Move up/down through the process list
Space # Tag/untag a process for bulk actions

# Sorting
P # Sort by CPU usage
M # Sort by memory usage
T # Sort by total time
F6 # Open sort column picker

# Actions
F3 or / # Search for a process by name
F5 # Toggle tree view
F7 / F8 # Decrease / increase nice value
F9 # Kill selected process (signal menu)
u # Filter by user
h # Open help screen
q # Quit htop

Note:

You can also use the mouse inside htop - click any column header to sort, click a process to select it, and click the function key labels at the bottom bar to trigger actions. Disable mouse support with htop -M if you prefer keyboard-only mode.

#09

htop vs top Command - Key Differences

Both tools monitor processes in real time, but they differ significantly in usability. top ships pre-installed everywhere; htop must be installed separately. Here is a direct feature comparison.

bash
LinuxTeck.com
# Launch the classic top
top

# Launch the modern htop
htop

♥ htop vs top - Feature Comparison
Feature htop top
Color-coded display ✅ Yes ❌ No
Mouse support ✅ Yes ❌ No
Scroll process list ✅ Yes ❌ Limited
Kill process interactively ✅ F9 key ⚠️ k key (enter PID manually)
Tree view ✅ F5 key ❌ No
Per-CPU bar graphs ✅ Yes ❌ No
Search by name ✅ F3 / / ❌ No
Pre-installed on Linux ❌ Needs install ✅ Yes

Tip:

Use top when working on a minimal or fresh server where htop is not yet installed. Once you have package manager access, install htop - you will rarely go back to top for interactive monitoring.

#12

Run htop as Root for Full System View

Running htop as a regular user hides some system-level processes. Use sudo htop to see everything - including kernel threads - and to renice or kill processes owned by root or other system users.

bash
LinuxTeck.com
# Run htop with full root privileges
sudo htop

# Combine with user filter to watch a system user as root
sudo htop -u mysql

Sample Output - additional kernel threads visible as root
PID USER PRI NI VIRT RES SHR S CPU% MEM% TIME+ Command
1 root 20 0 168M 11M 8.2M S 0.0 0.1 0:03.44 /sbin/init
2 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [kthreadd]
3 root -51 0 0 0 0 S 0.0 0.0 0:00.00 [rcu_gp]
512 mysql 20 0 1.8G 420M 32M S 1.2 5.4 2:14.07 /usr/sbin/mysqld

Danger - Root Kills:

Running sudo htop lets you kill any process on the system, including critical kernel threads and system daemons. Terminating the wrong process can crash services or destabilize the server.

Always double-check the process name and PID before sending a signal when operating as root.

END

Conclusion

The htop command in Linux is one of the most efficient tools for monitoring system performance. Whether you're trying to debug a slow server, monitor a long running script, or simply learn about how Linux manages its own processes; htop provides an immediate and actionable way to view your system’s performance. It's one tool that offers all the functionality of top but with a clean and fast interface.

Once installed, htop will be your new "go to" for system monitoring. htop in Linux has been described as being among the best ways to use your terminal in terms of utility. In addition to viewing CPU and memory usage in real-time, htop allows you to kill a rogue process, filter by user, renice jobs, and see what makes up a process tree.

FAQ

People Also Ask

What is htop used for in Linux?

htop is an interactive, real-time process viewer for Linux. It shows running processes, CPU usage, memory consumption, and allows filtering and process control. Refer htop man page.

Is htop better than top?

Yes. htop provides a better UI, mouse support, scrolling, and easier process management compared to top.

How do I install htop on Linux?

Use your package manager: sudo apt install htop, sudo dnf install htop, or sudo pacman -S htop.

How do I quit htop?

Press q, F10, or Ctrl+C to exit.

How do I kill a process in htop?

Select a process and press F9, then choose a signal like SIGTERM or SIGKILL.

Does htop work on all Linux distributions?

Yes, it is available on all major Linux distributions and even on macOS via Homebrew.

LinuxTeck - A Complete Linux Learning Blog
From your first terminal command to advanced sysadmin skills - every guide here is written in plain English with real examples you can run right now.

About Aneeshya S

Aneeshya S is a Senior Linux Trainer and System Administrator with over 10 years of experience. She actively follows emerging technologies and industry trends. Outside the terminal, she enjoys music and travel.

View all posts by Aneeshya S →

Leave a Reply

Your email address will not be published.

L