If your computer system’s per­for­mance is too slow or if it suddenly keeps freezing, you need to ask yourself: are un­de­tectable programs or processes running in the back­ground that are putting a strain on the system? And are they even­tu­al­ly causing these problems? The task manager (also known as 'process manager'), can answer this question. Since it collects in­for­ma­tion about all the active system processes, it presents them in a graph and dis­tin­guish­es the problem at hand. In addition to this mon­i­tor­ing function, task managers are also able to manage these processes: you can not only determine which programs and services are exerting a par­tic­u­lar strain on your system, but you can also terminate them.

htop: the open source solution with thread item­iza­tion

Current operating systems have process managers installed by default. If the operating system does not, they provide cor­re­spond­ing commands to display and manage processes. There are also al­ter­na­tive programs like htop, which are known to represent processed data in a better way and are much easier to use. Orig­i­nal­ly developed ex­clu­sive­ly as a Linux task manager, the GNU-licensed tool fulfills the tasks of the command top, which is used to display active processes on Unix-like systems. Fur­ther­more, the terminal is replaced by a text interface based on the C library, ncurses. In this manner, htop can be operated easily using the keyboard and without having to enter cum­ber­some commands. The process manager, which was published by Hisham Muhammad in 2004 and has been con­stant­ly evolving ever since, doesn’t just show the active tasks, but also their in­di­vid­ual threads. These im­ple­men­ta­tions provide a more detailed de­scrip­tion of the process in question, meaning that they allow an even more accurate eval­u­a­tion. There are some keyboard shortcuts for htop; in a desktop en­vi­ron­ment, the process manager can even be operated by mouse. If you use the latest ncurses library, you can use the mouse to scroll through the process overview. In addition to Linux dis­tri­b­u­tions such as Ubuntu, the task manager is also available to use on the Unix de­riv­a­tives, FreeBSD, OpenBSD, and Mac OS X.

The structure of the task manager for Linux

The htop interface is divided into three sections:

  • Header
  • Main section
  • Footer

By default, the two-part header shows the per­cent­age of the various processor cores as well as the capacity of the memory ('mem') and the swap file ('swp') in megabytes (MB) on the left. The right part provides in­for­ma­tion about the number of active tasks and threads, the status of the system battery, the system’s 'uptime' and the average 'system load' specified in three values. The header can be freely con­fig­ured so that, for example, instead of using the in­di­vid­ual processor cores, the re­spec­tive average value can be displayed.

The main area lists all active processes using the following values:

PID The process' ID
USER The process' owner
PRI The process' priority (the lower the number, the higher the priority)
NI The nice value of the process (re­spon­si­ble for the priority)
VIRT How much virtual memory is being used
RES How much physical RAM the process is using (measured in kilobytes)
SHR How much shared memory is being used
S The current status of the process (e.g. zombied, sleeping, running, etc.)
CPU% The per­cent­age of the processor time used by the process
MEM% The per­cent­age of physical RAM the process is using
TIME+ How much processor time has been used by the process
COMMAND The name of the command that started the process

The htop footer has different buttons that can be selected by mouse click. They can also be accessed using the function keys F1 to F10.

htop: function keys and other key commands

While other areas of the tool are only concerned with col­lect­ing processes and sta­tis­tics, the last-mentioned buttons on the footer are what are used to operate htop. It doesn’t matter whether you use the mouse or the keyboard. However, if you decide to use the keyboard, you will have a number of useful key commands that go beyond the pos­si­bil­i­ties of the function keys and make task manager work extremely easy. The ability of each function key and ad­di­tion­al shortcuts are sum­ma­rized here:

Key or key com­bi­na­tion Al­ter­na­tive(s) Function
[F1] [?] or [h] Displays the help menu
[F2] [Shift] + [s] Opens the con­fig­u­ra­tion menu
[F3] [/] Opens the search process
[F4] [\] Filters the processes according to name
[F5] [t] Activates/de­ac­ti­vates the tree view
[F6] [>] Opens the sort menu
[F7] ] Reduces the nice value of the selected process
[F8] [ Increases the nice value of the selected process
[F9] [k] Ends the selected process
[F10] [q] or [Strg] + [c] Ends htop
[Space bar]   Tags the selected process(es)
[Shift] + [u]   Removes all tags
[Shift] + [p]   Sorts processes according to CPU usage (CPU%)
[Shift] + [m]   Sorts processes according to memory usage (MEM%)
[Shift] + [t]   Sorts processes according to processor time (TIME+)
[u]   Allows a par­tic­u­lar user to be selected
[Shift] + [k]   Hides kernel threads (system-specific)
[Shift] + [h]   Hides user threads (ap­pli­ca­tion-specific)
[Shift] + [f]   Attaches the cursor to the selected process

How to install htop

As is common for open source programs, you can install htop using either source files or binary files and the package manager of each dis­tri­b­u­tion. Download and install the former with the following commands:

$ wget https://hisham.hm/htop/releases/2.0.1/htop-2.0.1.tar.gz
$ tar -xzvf htop-2.0.1.tar.gz
$ cd htop-2.0.1./
$ ./configure
$ make
# make install

If, on the other hand, you prefer the variant with the package manager, you should first ensure that the current htop version is included for your dis­tri­b­u­tion. If it is, then simply follow the usual in­stal­la­tion pattern for your system. For example, in Ubuntu, the task manager is set up by entering the following command:

sudo apt-get install htop

Con­clu­sion: self-ex­plana­to­ry and clear process manager

htop is a good example of the classic Unix command top and scores plus points with its ncurses-based text interface. As a result, the in­di­vid­ual processes and threads are not only presented in an appealing manner, but operating with a mouse or keyboard is a lot more intuitive than with pure command line tools. The clever use of function keys and various ad­di­tion­al key commands sim­pli­fies nav­i­ga­tion and con­fig­u­ra­tion, no matter whether processes should be ter­mi­nat­ed, or pri­or­i­ties should be changed. Besides top (that is already installed by default), there are al­ter­na­tives for ex­pe­ri­enced ad­min­is­tra­tors. This includes the similar process manager atop as well as the cross-platform tool Glances.

Go to Main Menu