DEV Community

Roberto Dip
Roberto Dip

Posted on • Originally published at monades.roperzh.com on

Weekly Command: managing processes with htop

overview

The basics

htop [-dChustv]

htop is an interactive command-line process manager that allows you to visualize, sort and manage processes running in your system.

As with many other great command-line utilities, htop is built with ncurses, so the interface may look familiar to you.

You can run the command without any flags and start interacting with your running processes immediately.

fun fact: the community has a list of TV shows and films where htop has appeared.

Examples

htop is very well designed, and your great ally is the help bar at the bottom, which makes the program very intuitive to use, nonetheless here are some examples.

Sending different signals

While the bottom-bar menu presents an option to kill the selected process with F9, you can send any signal to them by pressing the k key and selecting the desired signal.

Tagging multiple processes

Multiple processes can be marked and then signaled at the same time by using the tagging functionality. You can tag a process with the spacebar or a process with all its children with c.

To untag all processes at once you can use U.

Searching and filtering

You can search and filter processes incrementally by name by using F3 or / to search and F4 or \ to filter.

Leveraging arguments

Besides all the goodness of the user interface, you can also manage some of the features of htop when launching it via custom flags, here are some of my favorites:

  • --no-color starts the program in monochrome mode, personally, I find it very pleasant to use.
  • --pid=PID1,PID2... only shows the given comma-separated list of PIDs.
  • --tree shows the processes in the tree view.

Configuring

config

htop provides a nice interface to configure the UI: from the meters at the top to the number of columns displayed for every process, almost everything can be changed. This interface lives in the setup menu, which can be opened with F2, once there you will be presented with several menus to configure.

Your configurations are stored in ~/.config/htop/htoprc by default, and this file is automatically managed by htop so you shouldn’t have to manually change it. The path to the config file can be set with the $HTOPRC environment variable, allowing you to have different config files for different scenarios.

Top comments (0)