Htop, a process management tool that replaces top in Centos

Source: Internet
Author: User
1. htop introduction Thisishtop, aninteractiveprocessviewerforLinux. Itisatext-modeapplication (forconsoleorXterminals) andrequiresncurses. Comparisonbetweenhtop

I. INTRODUCTION to htop

This is htop, an interactive process viewer for Linux. It is a text-mode application (for console or X terminals) and requires ncurses.

Comparison between htop and top

  • In 'htop' you can scroll the list vertically and horizontally to see all processes and complete command lines.
  • In 'top' you are subject to a delay for each unassigned key you press (especially annoying when multi-key escape sequences are triggered by accident ).
  • 'Htop' starts faster ('top' seems to collect data for a while before displaying anything ).
  • In 'htop' you don't need to type the process number to kill a process, in 'top' you do.
  • In 'htop' you don't need to type the process number or the priority value to renice a process, in 'top' you do.
  • 'Htop' ororts mouse operation, 'top' doesn' t
  • 'Top' is older, hence, more used and tested.

Htop is an interactive process viewer in Linux. it is a text-mode application (in the console or X terminal) that requires ncurses.

Htop is more user-friendly than traditional Linux top. It allows users to perform interactive operations, supports color themes, supports horizontal or vertical scrolling of the process list, and supports mouse operations.

Compared with top, htop has the following advantages:

  • You can scroll through the process list either horizontally or vertically to view all processes and complete command lines.
  • It is faster than top at startup.
  • You do not need to enter a process number when killing a process.
  • Htop supports mouse operations.
  • Top is very old.

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

II. htop installation

A. install the source code package

# Tar zxvf htop-1.0.2.tar.gz

# Cd htop-1.0.2

#./Configure

# Make & make install

If an error occurs:

Configure: error: You may want to use -- disable-unicode or install libncursesw.

Install ncurses-devel

# Yum install ncurses-devel

B. RHEL/CentOS installation

You can install it through yum install htop, provided that you want to add the epel yum source. for details, refer to CentOS yum source configuration and usage.

# Rpm-ivh http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
# Rpm -- import/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL // import key
# Yum install htop

III. htop parameters

Type the htop command to open htop.

# Htop

The upper-left corner shows the CPU, memory, and swap zone usage, and the right side shows the task, load, and boot time. the following shows the real-time process status.

Below is the F1 ~ F10.

Shortcut Key Function Key Description Description
H ,? F1 Invoke htop Help View htop instructions
S F2 Htop Setup Menu Htop settings
/ F3 Search for a Process Search process
\ F4 Incremental process filtering Incremental process filter
T F5 Tree View Display tree structure
<,> F6 Sort by a column Select sorting method
[ F7 Nice-(change priority) Nice values can be reduced to increase the priority of the corresponding process.
] F8 Nice + (change priority) You can increase the nice value to reduce the priority of the corresponding process.
K F9 Kill a Process Transmit signals to processes
Q F10 Quit htop End htop

COMMAND-LINE OPTIONS)

-C -- no-color uses a monochrome color scheme.

-D -- delay = DELAY: Set the delayed update time, in seconds.

-H -- help: displays the help information of the htop command.

-U -- user = USERNAME only shows the process of a given user

-P -- pid = PID, PID... Show only the given PIDs

-S -- sort-key COLUMN sort by this COLUMN

-V? Version: displays version information.

INTERACTIVE COMMANDS)

Up/down keys orPgUP, PgDnSelect the desired process, the left and right keys, orHome, EndMove the field. you can also select the process with the mouse;

SpaceMark/unmark a process. Commands can act on multiple processes, such as "kill", and apply to all marked processes.

UUnmark all processes

SSelect a process and press "s" to trace the system call of the process using strace.

LDisplay files opened by the process: if lsof is installed, press this key to display the files opened by the process

IReverse the sorting order. if the sorting is positive, reverse the order, and vice versa.

+ ,-When in tree view mode, expand or collapse subtree. When a subtree is collapsed a "+" sign shows to the left of the process name.

A (on a machine with multiple processors)Set CPU affinity: Mark which CPUs a process can use

UDisplay specific user processes

MSort by Memory usage

PSort by CPU usage

TSort by Time + usage

FTrace process: if the sorting order causes the selected process to move everywhere on the list, let the selected process follow. This is useful for monitoring a process: in this way, you can keep a process visible on the screen. This function is disabled by using the direction keys.

KShow/hide kernel threads

HShow/hide user threads

Ctrl-LRefresh

NumbersPID search: Enter the PID and move the cursor to the corresponding process.

IV. use htop

4.1. display built-in help

Click Help or press F1 to display your Help

4.2. htop settings

Click Setup or press F2 to go to the htop setting page. the Meters page displays the top information, which is divided into the left and right sides, what can be displayed can be added in the rightmost column, to be added to the top left (F5) or right (F6), this is the range set by the individual. A clock is added here.

There are four display modes in the left and right columns: Text Bar Graph Led. I changed the cpu memory swap to Text display, and then the right column to Bar display. The clock is displayed in LED mode. The data display is almost the same, but it seems a little uncomfortable.

You can set the Display options according to your needs.

Color selection, in addition to basic color display, htop also provides the function of changing the panel. In fact, it only changes some color display settings. although we cannot customize the color display of details, but at least several styles are available.

The last setting is to adjust the display of Columns, that is, what data and information can be seen in the general htop command, and the adjustment of fields can be customized here, generally, you can use the default value of the system.

4.3. search process

Click Search or press F3 or enter "/" to enter the process name for Search, for example, Search for ssh

4.4. filter

Press F4 to enter the filter, which is equivalent to keyword search and case-insensitive, for example, filter dev

4.5. display the tree structure

Enter "t" or press F5 to display the tree structure, which is similar to pstree. you can see the tree structure of all programs, which is quite convenient for system management, clarify how programs are generated. of course, browsing in a tree structure can also be sorted by other data.

4.6. select the sorting method

By pressing F6, you can choose to sort by the cpu and memory content!

4.7 operating process

F7 and F8 correspond to nice-and nice + respectively, and F9 correspond to kill to send signals to the process. select the signal and press enter.

4.8. display the process of a user and select the user on the left.

Enter "u" and select a user on the left.

V. Alias top

Maybe you are used to top, and we can use top to open htop.

Edit the/root/. bashrc file and add the following code:

if [ -f /usr/local/bin/htop ]; then    alias top=’/usr/local/bin/htop’fi

# Source/root/. bashrc

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.