TrumanWong

htop

[Non-internal command] An interactive process viewer that can dynamically observe system process status

Supplementary instructions

The htop command is an interactive process viewer in Linux systems, a text-mode application (in the console or X terminal) that requires ncurses.

Compared with Linux's traditional top, htop is more user-friendly. It allows users to operate interactively, supports color themes, can scroll through the process list horizontally or vertically, and supports mouse operations.

Compared with top, htop has the following advantages:

  • You can scroll through the process list horizontally or vertically to see all processes and the complete command line.
  • Faster than top at startup.
  • There is no need to enter the process ID when killing a process.
  • htop supports mouse operations.
  • Comparing the two, top is more cumbersome.

topDisadvantages:

  • Only supports keyboard operation. -The display is also monotonous.

htop official website: http://htop.sourceforge.net/

htop installation

You won’t find htop pre-installed in most Linux distributions, but as one of the most popular utilities, you will find htop in the default repository of almost every Linux distribution.

So, if your machine is Debian/Ubuntu powered, the following command should do the job for you:

sudo apt install htop

Similarly, if you are using Fedora, you can use the following command:

sudo dnf install htop

If you are using CentOS or RedHat you can use the following command:

sudo yum install htop

If you want to avoid building the package from source, there is also a Snap package available:

sudo snap install htop

If you are using another distribution or want to build from source, you can download and install using wget: This requires you to download and install wget cmake

wget https://link.zhihu.com/?target=https%3A//hisham.hm/htop/releases/2.2.0/htop-2.2.0.tar.gz

tar -zxvf htop-2.2.0.tar.gz

cd htop-2.2.0/

./configure

make

make install

Of course, you can always refer to the htop's GitHub page for detailed instructions.

Note: The htop source code installation method defaults to the /usr/local directory. If you want to install it to another path, specify it through —prefix when executing configure. The format is: ./configure --prefix =/some/path

grammar

htop

Parameters

-C --no-color Use a single color color scheme
-d --delay=DELAY Set delay between updates, in ten seconds
-s --sort-key=COLUMN column sort (try --sort-key=help for a list)
-u --user=USERNAME Show only processes for a specified user
-p --pid=PID,[,PID,PID...] Show only to users
-h --help print help for this command
-v --version print version information

Parameter example

  • -C option: Set the interface to no color.

  • -d option: Set refresh time in seconds. For example, the htop -d 10 command will refresh every 10 seconds.

  • -s option: Sort by specified column. For example, the htop -s PID command will display the files sorted by the size of the PID column.

  • -u option: Display process information for the specified user. For example, the htop -u test command will only display related processes with the user name test.

Options

h,? F1: View htop usage instructions
S F2: Settings
/F3: Search process
\F4: Filter, search by keyword
t F5: Display tree structure
<,> F6: Select sorting method
[F7: Reduce the nice value so that the priority of the corresponding process can be increased
] F8: Increase the nice value, which can reduce the priority of the corresponding process
k F9: Kill the selected process
q F10: Exit htop


/ : search character
h : show help
l: Display the files opened by the process: If lsof is installed, press this key to display the files opened by the process.
u: displays all users and can select the process of a specific user
U: Unmark all processes
s: The system call that will call strace to trace the process
t: display tree structure

H: Show/hide user threads
I: Invert sort order
K: show/hide kernel threads
M: Sort by memory usage
P: Sort by CPU
T: Sort by running time

Up and down keys or PgUP, PgDn: move the selected process
Left and right keys or Home, End: move the list
Space: Mark/unmark a process. Commands can act on multiple processes, for example "kill" will apply to all marked processes

Htop settings

Click Setup or press F2 to enter the htop setting page.

1. Meters

Set the display information at the top, divided into left and right sides. The Left column represents the information displayed on the left side, and the Right column represents the information displayed on the right side. If you want to add new options, you can select Available meters to add, and F5 to add it to the upper left side, F6 is added to the upper right side. The options under the Left column and Right column can select the display method of information, including LED, Bar (progress bar), and Text (text mode), which can be set according to personal preferences.

2. Display options

Select the content to be displayed, press space x to display, after selecting, press F10 to save

3. Colors

Personally, I don’t think it’s very useful to set what color the interface should be displayed in. Everyone has different preferences.

4.Colums

The function is to add or cancel various contents to be displayed. After selection, F7 (move up), F8 (move down), F9 (cancel display, F10 (save changes)) are added here. PPID and PGRP are added according to everyone's needs. , display that information.

F3 Search Process

Press F3 or directly enter "/" in the interface to directly enter the search mode. The search is based on the process name. The searched processes will be marked with the set color for easy viewing.

F4: Filter

It is equivalent to fuzzy search and is not case-sensitive. After entering the content to be searched below, the interface will only display the searched content, which is more convenient to view.

F5: Display in tree mode

F6: Sort mode

After pressing F6, you will jump to a tree display interface, allowing you to choose how to sort. Under Sort by, select what you want to sort by.

F7, F8: Adjust the process nice value

F7 means to decrease the nice value (increase the priority), and F8 to increase the nice value (decrease the priority). Select a process and press F7 or F8 to increase or decrease the nice value. The nice value range is -20- 19

F9: Kill process

Select a process and press F9 to kill it, which is very convenient

F10:Exit htop