Commands you need to know: htop helps you know what to know | Detailed explanation of htop command under Linux system

I've been running something with a huge amount of calculations these days, and then I'm scratching my head and wondering how my process is going, whether I have enough computing resources, etc.! So use it extremely frequently htop! It should be said that I never quit, hahahahahahahahaha!
However, although I have a rough idea of ​​its interface, I don’t understand everything about it, so I just want to know more about it. After searching for a long time, I thought, now that I have learned everything, I might as well summarize it systematically, for the benefit of myself and everyone else! Um! so! I'm here with my notes!
Please tune in next - Commands to Know: htopHelping You Know What You Know

In order to better monitor the system's processes and system resource usage, we often use topcommands and htopcommands. They have similar functionality and are both interactive system monitoring tools, but differ in user interface and functionality. Personally, I still love it more htop! Because it really is, it’s so obvious at a glance! ! ! ! ! !

Let’s introduce them both! Then I’ll focus on the one I love more!

1 topcommand

command display interface

  • topIt is a basic command line tool in Linux systems, used to monitor system processes, CPU usage, memory usage, load and other system resources in real time.
  • topThe command interface is relatively simple and mainly displays the process list and system resource usage in text form.
  • topThe operation of the command is relatively simple. Common operations include pressing keys to switch the sorting mode, checking the usage of different resources, ending the process, etc.

2 htopcommands

command display interface

  • htopIt is a similar topprocess viewing tool, providing richer functions and a more friendly user interface.
  • htopThe command interface is more intuitive, using colored markers and bar graphs to display process list, CPU, memory, swap space, load and other information.
  • htopCommands support more interactive operations, such as using mouse clicks, shortcut keys to switch sorting methods, viewing and setting process priorities, terminating processes, etc.
  • htopIt also provides some additional functions, such as searching in the process list, monitoring the processes of specified users, etc.

After reading my above introduction, we can understand that htopcommands are more powerful and intuitive in terms of user interface and functions than topcommands, and are more suitable for scenarios that require more detailed information and more operation options. However, topas a basic tool that comes with the Linux system, commands can still meet the needs and are more lightweight in some cases.

3 htopdisplay interface

Next, let’s focus on htopthe display interface that I love more!

Note: htopThe interface may be slightly different depending on the operating system and version. What we are talking about today are based on common situations, and the specific details may be different!

htopThe interface displayed by the command mainly consists of the following four parts:

  1. Header Bar: Located at the top of the interface, it displays the overall status of the system, including CPU usage, memory usage, number of processes, etc.
  2. Process List: Located in the main part of the interface, it displays the currently running processes and their related information. Each row represents a process, and the columns display the process's ID, user, CPU usage, memory usage, process status and other information.
  3. Graphs Area: Located on the left, right or top of the interface (in our article at the top), it displays the usage of system resources in the form of a histogram, such as CPU usage, memory usage, disk read and write, etc. .
  4. Shortcut Keys Bar: Located at the bottom of the interface, it displays commonly used shortcut key operations, helps users quickly understand and use htopfunctions, and facilitates management and control.
    Show interface overview

3.1 Header Bar

The htoptitle bar contains some important system information, showing the overall status. look! Purple frame!

Display interface | title bar

  1. tasks: Displays the number of tasks (number of processes) in the system. Including the total number of tasks (total), the number of running tasks (running), etc.
  2. load average: Displays the average load of the system. Includes load average values ​​over 1 minute, 5 minutes, and 15 minutes. The load value represents the number of processes in the runnable state and the uninterruptible state per unit time.
  3. uptime: Displays the running time of the system. Indicates the time that has elapsed since the system was last started.

3.2 Process List

htopA process list will be displayed with detailed information about each process. look! Red frame!

Display interface | Process list

By default, processes are sorted by CPU usage, with the most CPU-intensive processes at the top. So! In order to make it easier for us to know better when we work!

Next, let's introduce to you htopthe meaning of each column in the process list displayed after running the command (this should be the part we need to understand most)!

  1. CPU column: Shows the usage of each CPU core, including the percentage of CPU usage for user space and kernel space, and the percentage of idle CPU.

  2. MEM column: Shows memory usage, including used and available physical memory and swap space.

  3. SWAP column: Shows swap space usage, including used and available swap space.

  4. PID column: displays the ID of the process, uniquely identifying a process.

  5. USER column: Shows the user running the process.

  6. PRI column: Displays the priority of the process.

  7. NI column: Displays the priority adjustment value of the process.

  8. VIRT column: Displays the amount of virtual memory used by the process.

  9. RES column: Shows the amount of physical memory used by the process.

  10. SHR column: Shows the size of shared memory used by the process.

  11. Column S: Displays the status of the process, such as running (R), sleeping (S), zombie (Z), etc.

    Here are some common S column options and their meanings:

    • R: Running, indicating that the process is currently running and occupying CPU resources.
    • S: Sleeping (Sleeping), indicating that the process is currently in a sleeping state, that is, waiting for certain events to occur and is suspended.
    • D: Uninterruptible Sleep, indicating that the process is waiting for certain I/O operations to be completed, and the process cannot be interrupted at this time.
    • Z: Zombie (Zombie), indicating that the process has terminated but has not yet been recycled by its parent process.
    • T: Stopped (Stopped), indicating that the process has been suspended, usually after receiving a stop signal.
    • t: Tracing/Stopped (Tracing/Stopped), indicating that the process is tracked by the debugger or has been stopped.
    • X:Dead, indicating that the process has been terminated or terminated abnormally.
  12. CPU% column: Shows the percentage of CPU used by the process.

  13. MEM% column: Shows the percentage of memory used by the process.

  14. TIME+ column: Displays the cumulative CPU time of the process.

  15. Command column: Displays the name of the command or program that was run.

3.3 Graphs Area

The histogram area can be divided into two small parts (my version is like this, others may be slightly different), the CPU status area and the memory status area. look! Pink frame!

Display interface | Histogram area

  1. mem: displays memory usage. Including total memory (total), used memory (used), free memory (free), cache and buffer occupied memory (buffers/cache), etc.
  2. swp: Displays swap space (swap) usage. Including the total amount of swap space (total), the amount of used swap space (used), the amount of free swap space (free), etc. When you find that your swap partition has been used, it means that your physical memory is insufficient and you need to consider adding more memory!

We found that these pillars are colorful. What do the different colors mean? Let’s chat in detail!

The first is the CPU status area (the top pink frame):

  • Green: Indicates idle CPU time. This means that the CPU is idle and not performing any tasks.
  • Blue or cyan: Indicates the CPU time of user mode (User). User mode means that the CPU is performing user-level tasks, such as running applications or user-defined processes.
  • Red: Indicates the CPU time of the kernel state (Kernel). Kernel state means that the CPU is performing kernel-level tasks, such as the operation of the operating system kernel, device drivers, etc.
  • Purple: Indicates CPU time for virtualization or hyper-threading. This indicates that the CPU is performing tasks related to virtualization or hyper-threading.
  • Yellow: Indicates waiting (Wait) CPU time. Wait time represents the time the CPU waits for an event to complete or for resources to become available, such as waiting for an I/O operation to complete.
  • White: Indicates other system-related CPU times, such as interrupts and soft interrupts.

Next is the memory status area (the pink frame on the left, including mem and swp):

  • Green: Indicates free memory. This represents the portion of memory that is not being used.
  • Blue or cyan: Indicates cache memory. Caching is when the operating system stores recently accessed data in memory for faster access.
  • Yellow: Indicates buffer memory. Buffer refers to the memory reserved by the operating system for I/O operations to speed up data transfer.
  • Red: Indicates used memory. This represents the portion of memory that is being occupied.
  • White: Indicates memory used by the kernel or other system-related memory.

Again, note: Different operating systems or versions may use different color schemes to represent the histogram of the memory status area, so the meaning of the specific colors may be different. It is recommended to consult the relevant documentation or resources to understand htopthe meaning of the command memory status area bar colors for a specific operating system or version.

3.4 Shortcut Keys Bar

htopIt also provides some interactive functions to help us control management, that is, the shortcut key prompt bar part. look! Yellow frame!

Display interface | Shortcut key prompt bar

The F1 - F10 keys provide some commonly used functions and operation options. These shortcut keys can help us htopquickly manage, filter and view processes in the app, and provide shortcuts for some common operations.

The following is an introduction to the functions of each key:

  • F1: View htopthe help document to learn more details about various interface items.
  • F2: Enter the settings menu, where you can make some global settings, such as sorting methods, display options, etc.
  • F3: Search in the process list. After entering the keyword, matching processes will be filtered and displayed.
  • F4: Enter filtering mode, where you can filter by specific attributes of the process, such as process status, user, etc.
  • F5: Refresh the interface and update the usage of processes and system resources.
  • F6: Switch the sorting mode and sort processes by different columns, such as CPU usage, memory usage, etc.
  • F7: Reduce htopthe displayed process list and only display some processes.
  • F8: Increase htopthe displayed process list and display more processes.
  • F9: Send a signal to the selected process, you can choose to terminate or send other signals.
  • F10: Exit htopthe command. Of course, you can also exit smoothly by pressing the q key on the keyboard! ! !

Note again: htopthe interface may be slightly different depending on the operating system and version. What we are talking about today are based on common situations, and the specific details may be different!

Public account: What newbies need to know
Bilibili: A little barbarian

Guess you like

Origin blog.csdn.net/weixin_43843918/article/details/130799190