Skip to content

htop Command in Linux: Install, Use and Keyboard Shortcuts

Learn the htop command in Linux: install it on Ubuntu, Debian, Fedora, RHEL and Arch, read the CPU and memory meters, sort, filter and kill processes.

On this page

htop is an interactive process viewer for Linux. It shows every running process with its CPU and memory use, updates the list live, and lets you scroll, search, filter, sort and kill processes with single keys or the mouse. Think of it as an easier, more colourful version of the top command.

To install and start it on Ubuntu or Debian:

sudo apt install htop
htop

Press q or F10 to exit. The rest of this guide shows how to install htop on other systems, read its screen, use the most useful keys, and run it with command-line options. Everything was tested with htop 3.3.0 on Ubuntu 24.04. Ubuntu 26.04 ships htop 3.4.1, which uses the same keys and options.

htop vs top

Both tools show running processes, and top is installed everywhere. htop adds a few things that make daily work faster:

Featurehtoptop
Scroll through the full process listYes, up/down and left/rightNo, only the first screen
Mouse supportYesNo
Kill or renice without typing a PIDYes, select the process and press a keyNo, you type the PID
Tree view of parent and child processesYes (F5)Partly (V in newer versions)
Act on several processes at onceYes, tag them with SpaceNo
Open strace and lsof for a processYes (s and l)No
Installed by defaultOn some distrosAlmost always

Install htop

htop is in the default repositories of nearly every distribution. Use the command for your system:

SystemCommand
Ubuntu, Debian, Linux Mintsudo apt install htop
Fedorasudo dnf install htop
Rocky Linux, AlmaLinuxsudo dnf install epel-release, then sudo dnf install htop
RHELEnable the EPEL repository, then sudo dnf install htop
Arch Linux, Manjarosudo pacman -S htop
openSUSE, SLESsudo zypper install htop
Alpine Linuxsudo apk add htop
macOS (Homebrew)brew install htop

On RHEL and its rebuilds, htop isn’t in the base repositories, which is why you need EPEL first. There is no htop for Windows. On Windows 10 and 11 you can run it inside WSL (for example, an Ubuntu WSL install) with sudo apt install htop, but it shows only the processes inside WSL, not Windows programs.

Check the installed version:

htop --version

htop 3.3.0

Run htop

Open a terminal, type htop and press Enter:

htop

As a normal user you can see all processes but only change (kill or renice) your own. To manage any process, run it with sudo:

sudo htop
htop command output in a Linux terminal
htop command in Linux

How to exit htop

Press q or F10. Ctrl+C also works. If the function keys don’t reach htop (some terminals and SSH apps use them for their own menus), use q.

Understanding the htop Screen

The htop screen has three parts: the meters at the top, the process list in the middle, and the function-key menu at the bottom.

The top meters

  • CPU bars (1, 2, 3 …): one bar per CPU core. The colours show what the time was spent on: blue for low-priority (niced) processes, green for normal user processes, red for the kernel, and cyan for virtual machine (guest) time.
  • Mem: RAM in use. Green is memory used by programs; blue (buffers) and yellow/orange (cache) is memory Linux borrows for disk caching and gives back when programs need it. The number on the right (for example 2.18G/7.77G) is used/total. A mostly yellow bar is normal and not a sign of low memory.
  • Swp: swap space in use. Swap that keeps growing means the system is short of RAM.
  • Tasks: for example 100, 104 thr; 1 running means 100 processes, 104 user threads, and 1 process using the CPU right now.
  • Load average: the average number of processes running or waiting over the last 1, 5 and 15 minutes. As a rough guide, a load higher than your number of CPU cores means processes are queuing.
  • Uptime: how long the system has been running. htop adds (!) after the days when the uptime passes 100 days, as a gentle reminder that the server may be missing kernel updates.

You can see the same memory numbers in plain text with the free command.

The process list columns

ColumnMeaning
PIDProcess ID
USERThe user who owns the process
PRIKernel priority of the process
NINice value, from -20 (highest priority) to 19 (lowest)
VIRTVirtual memory: everything the process has mapped, including memory it hasn’t used yet. Usually much bigger than RES and rarely useful on its own.
RESResident memory: the RAM the process is actually using. This is the number to watch.
SHRShared memory, such as libraries shared with other processes (part of RES)
SState: R running, S sleeping, I idle, D waiting on disk, Z zombie, T stopped or traced
CPU%Share of one CPU core used since the last update. A busy multi-threaded process can go above 100%.
MEM%RES as a percentage of total RAM
TIME+Total CPU time the process has used, in minutes:seconds.hundredths
CommandThe command line that started the process

Memory sizes without a letter are in KiB; M and G mean MiB and GiB. Highlighted values (like the red hours in the TIME+ column of the screenshot) just draw attention to large numbers.

Common Tasks in htop

Sort processes by CPU or memory

Press P (Shift+p) to sort by CPU, M to sort by memory and T to sort by CPU time. F6 opens a menu with every column you can sort by, and I inverts the order. You can also click a column header with the mouse.

Search and filter

  • F3 or / searches: the cursor jumps to the next process whose command matches what you type. Press F3 again for the next match.
  • F4 or \ filters: only matching processes stay in the list. The match is case-insensitive, and you can give several names separated by |, for example nginx|php-fpm. Press F4 and then Esc to clear the filter.

Show one user’s processes

Press u, pick a user with the arrow keys and press Enter. Choose All users to go back.

Tree view

Press F5 or t to show which process started which. Use + and - to expand or collapse a branch. Press F5 again to return to the normal sorted list.

Kill a process

  1. Select the process with the arrow keys or the mouse (or type its PID to jump to it).
  2. Press F9 or k.
  3. Pick a signal. 15 SIGTERM is selected by default and asks the program to close cleanly. Choose 9 SIGKILL only if the process ignores SIGTERM.
  4. Press Enter.

To kill several processes at once, tag each one with Space (or press c to tag a process and all its children) and then press F9. Press U to untag everything. Outside htop, see how to kill a process by ID or by name.

Change a process’s priority

Select the process and press F8 (or [) to lower its priority, which raises its nice value, or F7 (or ]) to raise it. Any user can lower the priority of their own processes; raising priority needs root, so run sudo htop for that.

See open files and system calls

Select a process and press l to list its open files with lsof, or s to watch its system calls live with strace. Both tools must be installed, and tracing other users’ processes needs sudo.

Customise the display

Press F2 to open Setup. There you can add or remove meters (for example disk I/O, network I/O or temperature), add columns such as IO_RATE or STARTTIME, and choose a colour scheme. htop saves your choices to ~/.config/htop/htoprc when you quit, so they are kept the next time you start it. Delete that file to go back to the defaults.

htop Keyboard Shortcuts

The function keys are listed at the bottom of the screen. Press h or F1 inside htop to see every shortcut.

KeyAction
F1, h, ?Help screen
F2, SSetup (meters, columns, colours)
F3, /Search by command name
F4, \Filter by command name
F5, tTree view on/off
F6, <, >Choose the sort column
F7, ]Higher priority (lower nice value, root only)
F8, [Lower priority (higher nice value)
F9, kKill: send a signal to the selected or tagged processes
F10, qQuit
P / M / T / NSort by CPU% / MEM% / TIME / PID
IInvert the sort order
uShow one user’s processes
SpaceTag or untag a process
cTag a process and its children
UUntag all processes
FFollow the selected process as the list re-sorts
HHide or show user threads
KHide or show kernel threads
pShow or hide full program paths
lList open files (lsof)
sTrace system calls (strace)
eShow the process’s environment variables
aSet CPU affinity (which cores it may use)
ZPause or resume screen updates
NumbersJump to a PID as you type it
htop help screen with keyboard shortcuts
htop help screen (press h)

Keys are case-sensitive: u picks a user but U untags all processes, and k kills while K hides kernel threads.

htop Command-Line Options

You can set most of these from inside htop, but options are handy for scripts, aliases and quick checks.

OptionWhat it does
-u USERShow only processes of USER
-p PID,PIDShow only the given process IDs
-F NAMEStart with a filter, like pressing F4
-s COLUMNSort by a column (htop -s help lists the names)
-tStart in tree view
-d NUpdate every N tenths of a second (default 15, so 1.5 s)
-n NExit after N updates
-HHighlight new and exiting processes
-CNo colours (monochrome)
-MDisable the mouse
--readonlyDisable kill, renice and other changes

Some examples:

htop -u www-data          # only processes of the www-data user
htop -p 1234,5678         # watch two specific processes
htop -s PERCENT_MEM       # sort by memory on start
htop -t -F nginx          # tree view, only nginx processes
htop -d 50                # refresh every 5 seconds
htop --readonly           # safe view, nothing can be killed

To watch a single program by name, combine -p with pgrep:

htop -p $(pgrep -d, nginx)

pgrep -d, prints the matching PIDs separated by commas, which is the format -p expects.

Troubleshooting

  • htop: command not found: htop isn’t installed. Install it with the command for your distribution above. On RHEL, Rocky and AlmaLinux, enable EPEL first.
  • Function keys open a terminal menu instead: use the letter shortcuts (h, S, /, \, t, k, q), or click the labels at the bottom of the screen.
  • Kill or renice does nothing: you are trying to change another user’s process. Quit and start sudo htop.
  • Strange characters instead of lines and bars: the terminal doesn’t handle Unicode. Start htop with htop -U to use plain ASCII.
  • Each process appears many times: you are seeing its threads. Press H to hide user threads.

FAQ

What is htop in Linux?

htop is a free, open-source, interactive process viewer. It shows running processes and CPU, memory and swap usage in real time, and lets you sort, search, filter and kill processes from the keyboard or the mouse.

How do I exit htop?

Press q or F10. Ctrl+C also closes it.

How do I install htop?

Use your package manager: sudo apt install htop on Ubuntu and Debian, sudo dnf install htop on Fedora (and on RHEL, Rocky Linux or AlmaLinux after enabling EPEL), sudo pacman -S htop on Arch, or brew install htop on macOS.

Is htop better than top?

For interactive use, usually yes: it scrolls, supports the mouse, shows a tree view and lets you kill or renice processes without typing PIDs. top is still useful because it is installed on almost every system and works well in batch mode (top -b) for scripts.

Why is the memory bar almost full?

Most likely it is cache (the yellow/orange part). Linux uses free RAM to cache files and releases it as soon as programs need memory. Look at the green part, which is memory actually used by programs.

How do I filter htop by user?

Press u inside htop and pick the user, or start it with htop -u username.

Is there htop for Windows?

No. You can run htop inside WSL on Windows 10 and 11, but it shows only the Linux processes in WSL. For Windows programs, use Task Manager or Resource Monitor.

Conclusion

htop gives you a live, readable view of what your Linux system is doing and lets you act on it in a keystroke: P and M to find the busiest processes, F4 to filter, F5 for the tree, and F9 to kill. For a quick text-only check on a minimal server, the top command cheat sheet covers the tool that is always there.

Rahul

Rahul Kumar is the founder and chief editor of TecAdmin.net. A Red Hat Certified Engineer (RHCE), he has worked in IT since 2009, with hands-on experience in Linux system administration, DevOps, web hosting, cloud platforms and automation. He started TecAdmin in 2013 to share practical, step-by-step guides, and leads its editorial work with one aim: making technical learning clear and useful for sysadmins, developers and beginners alike.

Leave a Reply

Your email address will not be published. Required fields are marked *


Back to top