Why Linux's htop command beats the top command

In Linux systems, the top command is used to display the real-time status of the running processes in the system. It displays some very useful information, such as CPU utilization, memory consumption, and each process. But, you know what? There is another command line tool, 'htop', which has the same functionality as the traditional top command, but has more power and can display more information. In this article, we will discuss the 'htop' command with an example.

htop command in Linux

Here is the relevant description excerpted from the htop man page:

It's similar to the top command, but lets you scroll vertically and horizontally, so you can see all the processes running on the system, along with their full command lines.

You can perform related operations (killing, renicing) on ​​this process without entering the PID of the process.

First understand its output

The htop command displays information in an intuitive format. Below is a snapshot of HTOP's output:

htop

htop

If you look at the upper-left part of the window, you will see real-time information on CPU load, memory consumption, and swap space displayed, and information on tasks, threads, load average, and system uptime in the upper-right corner.

The load average section provides three numbers, which simply represent the system load average over the past 5, 10, and 15 minutes. On a single-core system, a load average of 1 means 100 percent CPU utilization. Finally, the number indicated by the uptime is the total running time from the system startup to the current time.

Below, we will discuss this command further with an example.

1. Edit the configuration with the F2 key

The htop command offers many customization options, all you have to do is press the F2 key from the main window.

Shown below are the available customization options:

htop-settings

htop-settings

Just use the arrow keys to select and change specific settings.

2. Send signal via F9 key

The htop command allows you to easily send arbitrary signals to a process within the htop window. Just press the F9 key.

signals

signals

As you can see, the left part of the window lists all available signals and the right part lists processes. Just select a signal, select a process, and press enter, and the selected signal will be sent to that process.

3. Display a tree view of the process

The htop command also provides a tree view of processes. Press F5 to toggle.

Here is an example of htop displaying tree view information:

treeView

treeView

To exit tree view mode, press F5 again.

4. Search for a process with the F3 key

The htop command provides an easy-to-use way to search for processes. Press F3 and a text box will appear at the bottom of the window.

Here is an example:

search

search

As you can see, a text prompt box called 'Search' appears at the bottom of the window, where you can enter the name of the process and hit enter to search. If found, it will highlight the process in the list of processes listed.

5. Use the spacebar to set the color-coded process entry

In a real-time view of the processes running in the system, tracking down a process is a big problem. Because the entire list is constantly being refreshed, the order of the processes is also changing. For this problem, htop provides a very simple solution: color annotation. Yes, you can label a process entry and it will be displayed in a different color, so it becomes easier to keep track of it.

To mark a process entry, all you need to do is select the entry and press the 'Space' key. For example, in the screenshot example below, I've color-coded three process entries:

color-tag

color-tag

So with this method, you can easily trace the process you want to see.

6. Command Line Options

In addition to some of the hotkeys described above, htop also provides useful command-line options. Here are some of them:

  • -s option: sort by the specified column. For example, the htop -s PID command is displayed sorted by the size of the PID column.
  • -u option: Display a list of process information for the specified user. For example, the htop -u himanshu command will only display the relevant processes with the user name himanshu.
  • -d option: Set the refresh delay time. For example, the htop -d 100 command will cause the output to refresh after 1 second (the unit of parameter -d is 10 microseconds).

via: http://linoxide.com/linux-command/linux-htop-command/

Translator: runningwater  Proofreader: Caroline

 This article was originally translated by  LCTT , and was launched by Linux China  with honor

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325210146&siteId=291194637