Introduction
Many are familiar with Linux's top
command-line utility, which helps monitor processes consuming the most CPU or memory. Although top
is included by default in almost every distribution, there's an enhanced version available called htop
. This improved utility can be downloaded from most repositories.
htop
is an interactive system-monitor process viewer, designed as an alternative to the Unix program top
. It displays a frequently updated list of all running processes on a computer, usually ordered by CPU usage. Unlike top
, htop
provides a complete list of processes instead of just the top resource-consuming ones. It also uses color to give visual information about processor, swap, and memory status.
For this tutorial, we'll be using Ubuntu 16.04, but the instructions should work for all Debian and Ubuntu distributions offered by VPS SELL.
Update System
First, we recommend updating your server. This can be done by executing the following command:
apt-get update
Installation
Once your server is up to date, you can proceed with the installation. This requires running a single command:
apt-get install htop
With that, htop
is installed and ready to use.
Usage
To launch htop
, simply type htop
in a terminal. You'll notice a great text-mode graph at the top of the display. The output is similar to top
, but it is colorized and more interactive.
Use the Up/Down arrow keys to select a process. From there, you can kill the selected process with the F9 key or change its priority using the F7 and F8 keys. You can also easily change the default sort column using the F6 key.
Here are some additional keys to help you use htop
more effectively:
- M: Sort processes by memory usage
- P: Sort processes by processor usage
- ?: Access help
- k: Kill the current or tagged process (F9 can also be used for this)
- F2: Setup
htop
. You can choose display options here.
- /: Search processes
There are many more options available through the help or setup menus. These should be your first stops when exploring htop
's functionality.