In this KB
- What is the htop command
- How to use htop command under SSH Terminal
- How to process information obtained
The htop is a command line utility that allows you to interactively monitor your system’s vital resources or server’s processes in real time. In this guide, we will cover how you can use this command and briefly explain its different sections one by one.
Step 1: Connect Your Server with SSH
You need to connect your server through SSH connection. Instructions can be found here.
Step 2: Using htop Command Under SSH Terminal
Once your server is connected with SSH, you can run Htop command by just typing htop and press Enter. A screen will open up as a result of this command and will look like as the below screenshot.
The whole window above can be split up into three sections for the ease of our understanding. The top-left section comprises the CPU and memory usage information. The top-right section provides info about load average and uptime. The rest of the information contains real time data of processes with stats like priority, CPU and memory consumption etc.
We will cover these sections one by one.
Starting from top left, there is a CPU line which shows the percentage of CPU being used. For a single core CPU, there will be one line for it. In the case of multi-core CPUs, there will be n number of lines depending on the number of CPU cores. In any case, if CPU percentage is near 0 marks then it means CPU is not having much load and if it approaches 100 for a long time, it means CPU is under load.
Color coding of CPU usage lines:
The lines indicating CPU and Memory usage have a color coding of CPU.
Following colors indicate the type of process:
Red = Kernel process
Green = Normal user process
Blue = Low priority process
Next line denotes memory being consumed by the process running on the server, this is denoted by the number of memory used out of total memory.
Color coding of Memory usage lines:
Green: Used memory pages
Blue: Buffer pages
Yellow: Cache pages
It is the average of computational work performed by CPU. 1.0 on a single core CPU would mean 100 percent utilization, similarly, 2.0 on a dual core CPU represents 100% CPU usage.
Load average contains three values. The first number is one minute average(0.00 in the figure above), the second number is 5 minutes average (0.01 in above figure) while the third number is fifteen minutes average (0.05 in the figure).
The information below shows the information of processes running on your server.
As shown in above figure the following words denote:
PID: Unique Process ID.
USER: Process Owner.
VIRT: Virtual memory being consumed by process
%CPU: The percentage of the processor time used by the process.
%MEM: The percentage of physical RAM used by the process.
COMMAND: The name of the command that started the process.
The htop footer contains its menu command.
These commands can be used to do various functions for e.g. F6 Sort By can be used to sort the process via CPU usage and memory usage.
In a nutshell, htop is a useful command line tool in Linux environment to determine the cause of load by each process. It is similar to Task Manager in Windows OS environment. It can be used to troubleshoot and kill a process which is utilizing excessive server resources.