Home > System Tutorial > LINUX > linux htop An in-depth understanding of the top command under Linux: performance analysis tools and common options

linux htop An in-depth understanding of the top command under Linux: performance analysis tools and common options

WBOY
Release: 2024-06-02 12:24:58
Original
624 people have browsed it

1. top command

1 Introduction

The top command is a commonly used performance analysis tool under Linux. It can display the resource usage of each process in the system in real time, similar to the Windows Task Manager. top is a dynamic display process, that is, the current status can be continuously refreshed through the user's keyboard. If this command is executed in the foreground, it will occupy the foreground exclusively until the user terminates the program. To be more precise, the top command provides real-time control of the system. Processor status monitoring. It will display a list of the most "sensitive" tasks for the CPU in the system. This command can sort tasks by CPU usage, video memory usage and execution time; and many features of this command can be accessed through interactive commands or Then set it in the personal customization file.

2. Common options

-b: Operate in batch mode;

-c: Display the complete treatment command;

-d: Screen refresh interval;

-I: Ignore the failure process;

-s: Confidential mode;

-S: Accumulation mode;

-i: Set the interval time;

-u: Specify user name;

-p: Specify the process;

-n: The number of times to display in a loop.

3. Introduction to each parameter output by the top command

[root@hpf-linux ~]# top -bn1
top - 21:50:48 up 4 min,  2 users,  load average: 0.00, 0.02, 0.00
Tasks: 102 total,   1 running, 101 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.5%us,  0.8%sy,  0.0%ni, 98.4%id,  0.2%wa,  0.0%hi,  0.1%si,  0.0%st
Mem:   1030416k total,   141908k used,   888508k free,    14684k buffers
Swap:  2047996k total,        0k used,  2047996k free,    51848k cached
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND          
    1 root      20   0  2900 1412 1204 S  0.0  0.1   0:01.34 init              
    2 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kthreadd          
    3 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/0      
    4 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ksoftirqd/0      
    5 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 stopper/0        
    6 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 watchdog/0        
    7 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/1      
    8 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 stopper/1        
    9 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ksoftirqd/1      
   10 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 watchdog/1        
.................................
Copy after login

3.1. System running time and average load

top-21:50:48up4min,2users,loadaverage:0.00,0.02,0.00

illustrate:

3.2、Task

Tasks:102total,1running,101sleeping,0stopped,0zombie

illustrate:

The second line shows the summary of the task or process. Processes can be in different states. The number of all processes is shown here. In addition, there are the number of running, sleeping, stopped, and zombie processes (zombie is a state of a process). This process summary information can be toggled with 't'.

3.3, CPU status

Cpu(s):0.5%us,0.8%sy,0.0%ni,98.4%id,0.2%wa,0.0%hi,0.1%si,0.0%st

illustrate:

3.4. Memory usage

Mem:1030416ktotal,141908kused,888508kfree,14684kbuffers

Swap:2047996ktotal,0kused,2047996kfree,51848kcached

illustrate:

接出来两行显示显存使用率linux定时关机命令,有点像'free'命令。第一行是化学显存使用,第二行是虚拟显存使用(交换空间)。化学显存显示如下:全部可用显存、已使用显存、空闲显存、缓冲显存。相像地:交换部份显示的是:全部、已使用、空闲和缓冲交换空间。显存显示可以用'm'命令切换。

3.5、字段列

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND          
    1 root      20   0  2900 1412 1204 S  0.0  0.1   0:01.34 init              
    2 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kthreadd          
    3 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/0      
    4 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ksoftirqd/0      
    5 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 stopper/0        
    6 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 watchdog/0        
    7 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/1      
    8 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 stopper/1        
    9 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ksoftirqd/1      
   10 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 watchdog/1
Copy after login

说明:

S:这个是进程的状态。它有以下不同的值:

D-不可中断的睡眠态。

linux htop_linux htop_linux htop

R–运行态

S–睡眠态

T–被跟踪或已停止

Z–僵尸态

还有许多在默认情况下不会显示的输出,它们可以显示进程的页错误、有效组和组ID和其他更多的信息。

二、htop命令

1、htop命令简介

top作为日常管理工作中最常用也是最重要的Linux系统监控工具之一,可以动态观察系统进程状况。但其缺点就是只支持鼠标操作,显示也单调。作为刚刚Windows转入Linux的我来说,现今有了一个更好的选择:htop。htop是Linux系统下一个基本文本模式的、交互式的进程查看器,主要用于控制台或shell中,可以取代top,或则说是top的中级版。

htop命令优点:

1)快速查看关键性能统计数据,如CPU(多核布局)、内存/交换使用;

2)可以纵向或横向滚动浏览进程列表,以查看所有的进程和完整的命令行;

3)杀坠入程时可以直接选择而不须要输入进程号;

4)通过键盘操作条目;

5)比top启动得更快;

2、安装htop

[root@example.com ~]# yum install -y htop
Copy after login

3、常用功能键

linux htop_linux htop_linux htop

键入htop命令,打开htop:

里面左上角显示CPU、内存、交换区的使用情况,右侧显示任务、负载、开机时间,下边就是进程实时状况。

下边是F1~F10的功能和对应的字母快捷键:

命令行选项(COMMAND-LINEOPTIONS):

Interactive commands (INTERACTIVECOMMANDS):

4. Display instructions

The left part from top to bottom is the usage of CPU, memory and swap partition. The right part is: Tasks is the total number of processes, the number of currently running processes, Loadaverage is the system 1 minute, 5 Minutes, the average load condition in 10 minutes, and Uptime is the system running time.

5. htop usage instructions

F1: Display help information

wKiom1aV4_aCg3inAABr_4lVmHQ933.png

linux htop_linux htop_linux htop

F2Htop Settings

wKioL1aV5ELAmpxeAABF1w8y9PA575.png

Under Setup option:

Set the display information at the top, divided into left and right sides. Leftcolumn represents the information displayed on the left linux htoplinux htop, Rightcolumn represents the information displayed on the left. If you want to add a new option, you can select Availablemeters to add, F5 to add to the upper two sides, F6 to add to the upper two sides. The options under Leftcolumn and Rightcolumn can select the information display method, including LED, Bar (progress bar), and Text (text mode), which can be set according to personal preferences

wKioL1aV5FegJb6DAABGb_xQiwY998.png

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

wKiom1aV5DiQji_QAAAnuj2S0Wg248.png

Set the colors in which the interface is displayed.

The function is to reduce or cancel the various contents to be displayed. After selecting, F7 (downward communication), F8 (upward communication), F9 (cancel display, F10 (save changes)) will display this information according to individual needs.

F3 Search Process

Press F3 in the interface or directly enter "/" to directly enter the search mode, which searches based on the process name. Such as

linux htop_linux htop_linux htop

The searched processes will be marked with the set color for easy viewing.

F4: Filter

Equivalent to fuzzy search, case-insensitive, after entering the content to be searched below, the interface will only display the searched content, making it more convenient to view, such as:

F5: Display in tree form

F6: Sorting method

After pressing F6, you will jump to the interface shown above, allowing you to choose which methods to sort. Under Sortby, select which methods you want to sort by.

F7,F8: Adjust the process nice value

F7 means to reduce the nice value (reduce the priority), F8 to reduce the nice value (reduce the priority) Linux command detailed dictionary, select a process, press F7 or F8 to reduce or decrease the nice value, the nice value range for -20-19.

F9: Kill process

Select a process and press F9 to kill this process.

F10:Exit htop

Extended learning:

The above is the detailed content of linux htop An in-depth understanding of the top command under Linux: performance analysis tools and common options. For more information, please follow other related articles on the PHP Chinese website!

source:itcool.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template