Skip to content
Related Articles

Related Articles

Improve Article

Using htop to Monitor System Processes on Linux

  • Last Updated : 30 Jun, 2021

htop a Linux tool that is used in process-managing and terminal-based system monitoring. It allows real-time monitoring of processes and performs every task to monitor the process in the Linux system. The tool is written in the C programming language by Hisham Muhammad. It displays a complete list of processes running on the system and gives information on CPU use, memory and Processor. With the help of htop, we can sort the processes depending on CPU, memory use, and processes run by the user. There are various commands and options available for the htop command

Installation

  • Ubuntu/Linux
$ sudo apt-get install htop
  • CentOS/RedHat/Fedora
sudo dnf install htop
  • Mac
brew install htop
  • From source file 

To install the latest version of htop you can download the tarball file from here. To extract the tarball file use the command, htop.tar.gz is the name of the file you download.

tar -zxvf htop.tar.gz

Go to the extracted htop directory using cd.

cd htop

To compile htop execute these commands

./configure
make
sudo make install

Getting Started with htop

After we’re done with the installation of htop tool, we can now launch it by entering htop command in the terminal.



 In the topmost left corner, CPU usage is depicted by percentages using different color bars for different types of processes, and the core of the CPU is denoted by the number of bars. Two Modes of CPU Metric are

  • Default Mode
  • Detailed Mode

Color denotation for Default Mode is given in the following:

  • Blue: Low priority thread (nice > 0)
  • Green: Normal Priority thread (for users)
  • Red: Kernel Thread (kernel, iowait)
  • Orange: Virt time (steal time + guest time)

Memory Usage and Swap are present below the CPU Usage bars. It displays the amount of memory consumed by processes. 

  • Green: RAM Consumption by Memory Pages
  • Blue: RAM Consumption by Buffer Pages
  • Orange: RAM Consumption by Cache Pages

Swap Usage of System

Tasks, Threads, Running Processes, Load Average, and Uptime are shown in the system which is present next to the color bars.

Tasks – Shows the number of open processes present in the system. Here it displays  3 values that include the total number of tasks (77), the number of threads (147 thr), and the number of tasks currently running (1 running).

Load Average – Shows the average load of the system by CPU. Three average load numbers are displayed: Average load of system for last 1 minute  (0.13), average load of the system for last 5 minutes (0.49), average load of system for last 15 minutes (0.57) 



Uptime – Total system uptime from the last reboot.

Htop Menu

Customizations are done in htop setup menu and to access the menu press F2. There are four categories where you can customize the top menu: Setup, Left Column, Right Column, and Available Meters. They are used to configure meters, set display options, set color patterns and choose the columns to print them in order.

Display Options

Customizing display using htop command by pressing F2 and then navigate to display options. In the settings we have chosen highlight new and old processes where it’ll separate all the old and new processes and display them. 

By navigating to the display column we can change the display options for htop terminal, here we have changes the color of the terminal to black night.

Using htop commands

On htop, you can scroll horizontally and vertically with the help of “Up and Down” and “Left and Right” keys to scroll through processes. 

  • Kill process using htop: Select the process and press F9 or k to display the signal menu where there is a list of signals for the process. Then choose “SIGKILL” to kill the chosen process and press enter. Here we kill the signal with PID 1989. To multiple processes select a process and click the spacebar which will tag the selected process. After that, the changed tag of the process will change the colour and then scroll through the list to tag multiple processes. Press F9 to kill all tagged process.

Note: Press space bar to untag specific tagged process and press U to untag all tagged processes



  • Output Sorting: In this menu, it has different options to sort the output and to display output options press the F6 key, then, select the criteria as per your choice to sort the output by default it is set PERCENT_CPU

For PERCENT_MEM sorting, choose the option and hit enter.

  • Process in tree format: We can display the process in tree-like order or hierarchical order by creating a parent-child relationship. To do so, press F5.

  • Filter processes: To filter the process,Here press F4 function key. You have to enter the path in the footer section where you’re prompted to give the input by providing the path i.e “/usr/bin”

  • Search Processes: Press F3 key to search through processes and type the name in the search prompt. Here we will search for ryslogd process in  /usr/bin path. After searching, it will be highlighted in yellow.

To check what other shortcuts are available for the htop command, then you can press F1 key, then a list of key options will be displayed. 




My Personal Notes arrow_drop_up
Recommended Articles
Page :