Htop, how to install it and control the processes in Ubuntu 17.10

about htop

In the next article we are going to take a look at htop. This is one utility to monitor and manage system processes, which runs in the terminal. We have already talked about her before in this blog, in an article in which we talked about “how to kill processes and get system information”, But today we are going to look at it a little more in depth as it is a very useful tool.

It must be said that this is similar to another known utility called top, but htop is much easier to use. The user interface of the htop program is based on ncurses. The representation of the information is really clean. With this tool you can filter, manage and do other interesting things about the processes running on your system. It is a great tool for Gnu / Linux system administrators. In this article, we will see how install htop on Ubuntu 17.10 Artful Aardvark and some basics on how to use htop. Although all this you can do in other versions of Ubuntu.

Install htop

First we are going to update the cache of the package repositories of our Ubuntu operating system by writing the following command in the terminal (Ctrl + Alt + T):

sudo apt-get update

Once the package repository cache is updated we will see that htop is available in the official Ubuntu 17.10 Artful Aardvark repository. To install htop, run the following command in the same terminal:

sudo apt-get install htop

After this htop should be installed in our system. Now run the following command to start htop:

htop

This is the main htop window.

htop interface

Htop basics

the interface

To start let's see the htop program interface.

htop laptop on time

In the section marked in the above screenshot, you can see the team uptime. As you can see, my laptop has been running for 59 minutes and 44 seconds.

htop cores

We will also be able to find the amount of CPU used. You can see that this computer has 4 cores in my processor with different percentages of use.

We can also find how much main memory or RAM is available and how much is used. We will be able to find at the same time how much swap space is available and how much space is used.

ram swp top

As you can see, on this computer I have 7.78 GB of available RAM and 2.31 GB used.

Find a process

With this tool we will be able search for a specific process. For example, suppose we want to find the process 'firefox'.

First press the 'F3' key. A search box should appear as shown in the screenshot below.

search firefox top

In the search box type 'firefox'. You should see the selected firefox process as shown in the screenshot above. We can see that the id, in this case, the process (PID) is 2382 and is owned by the user sapoclay.

For go to the next process from Firefox or to the search result, press' againF3'. Once you find the process you are looking for, press'Intro'to select it.

Kill a process

We can also kill processes with htop utility. First select a process using the arrow keys'arriba'Y'down'I looking for a process using the key'F3'. Let's say that the PID 2382 is the one of the process that we want to kill. Select the process by doing it in the same way as indicated in the previous section.

Now to kill the process, press the 'F9' key. You should see the htop screen as shown below:

sigterm firefox htop

In the marked section, there are different signs listed. These signals are used to manage Gnu / Linux processes. To kill a process, the default signal for htop is TARGET TERM. Of course, you can choose any other signal using the keys'arriba'Y'down'.

Once you select the signal you want to send to the process, press the 'Enter' key . I suggest you send the default signal SIGTERM if you don't know what to do here. The process should be removed from the list immediately.

Switch to tree view or ordered view

htop ordered list

The default view mode of htop is sorted. Though we can move between the ordered view and the tree view if we wish, pressing 'F5' which will change the way in which the list of commands is displayed.

Htop window customization

We can go to the htop configuration window by pressing the 'F2' key, as you can see in the following screenshot.

Htop configuration window

From here you can customize the main htop window. For example, we can hide or show things, change colors and much more. But this configuration is beyond the scope of this article, although it should be easy enough to solve for each user.

Once you are done managing your processes, you can exit htop by pressing the 'q' key.


Leave a Comment

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

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.