Most people are familiar with Linux’s top command line utility to see what process is taking the most CPU or memory. Although top is included in almost every distribution by default, an improved version, called htop is available for download from most repositories.
htop is an interactive system-monitor process-viewer. It is designed as an alternative to the Unix program top. htop shows a frequently updated list of the processes running on a computer, normally ordered by the amount of CPU usage. Unlike top, htop provides a full list of processes running, instead of the top resource-consuming processes. htop uses color and gives visual information about processor, swap and memory status.
For this tutorial we are using Ubuntu 16.04 distribution, however you should be able to use it for all Debian and Ubuntu distributions we offer on Time4VPS.
First things first. Like always, first of all, we recommend to update your server. It can be done by simply executing:
After our server is up to date we can start installation. In this case it will be only one command to run:
apt-get install htop
That’s it, htop is installed and ready to be used.
Just type htop at a terminal to launch it, and notice the great text-mode graph at the top of the display. We can see that it has quite similar output to top, but is colorized, and is more interactive:
Use your Up/Down arrow keys to select a process, and then you can kill it with the F9 key if you’d like, or you can change the priority by using the F7 and F8 keys. You can also use the F6 key to change the default sort column really easily.
Here are some keys that will help you use htop more effectively:
M: Sort processes by memory usage
P: Sort processes by processor usage
?: Access help
k: Kill current/tagged process (You can use F9 as well as mentioned before)
F2: Setup htop. You can choose display options here.
/: Search processes
There are plenty of options that you can access through help or setup. These should be your first stops in exploring htop’s functionality.