search
HomeOperation and MaintenanceLinux Operation and MaintenanceDetailed analysis of top command parameters in Linux

This article brings you knowledge about the top command in Linux, including the usage of the top command and the meaning of each output parameter. I hope it will be helpful to you.

Detailed analysis of top command parameters in Linux

top command usage

The top command is often used to monitor the system status of Linux. It is a commonly used performance analysis tool that can display the status of each process in the system in real time. Resource usage.

How to use top top [-d number] | top [-bnp]

Parameter explanation:

-d: number represents the number of seconds, indicating the number displayed by the top command The interval between page updates. The default is 5 seconds. -b: Execute top in batch mode. -n: used in conjunction with -b, indicates that the output results of the top command need to be performed several times. -p: Specify a specific pid process number for observation.

On the page displayed by the top command, you can also enter the following keys to perform the corresponding functions (note that they are case-sensitive):

?: Display the commands that can be entered in top. P: Use the CPU's Sort by resource usage and display M: Sort by memory resource usage and display N: Sort by pid and display T: Sort by accumulated time used by the process and display k: Give a signal to a certain pid. Can be used to kill the process r: re-customize a nice value (i.e. priority) for a certain pid q: exit top (you can also exit top with ctrl c).

The meaning of each output parameter of top

The following is a screenshot of using the top command to perform performance testing:

Figure 1 (ubuntu):

Figure 2 (centos):

1. Statistical information of the first 5 rows of top

Row 1: top - 05:43:27 up 4:52, 2 users, load average: 0.58, 0.41, 0.30
The first line is the task queue information, its parameters are as follows:

##05:43:27represents the current timeup 4:52The system running time format is hours: minutes##2 usersload average: 0.58, 0.41, 0.30load average: If this number is divided by the number of logical CPUs, if the result is higher than 5, it indicates that the system is overloaded.
Content Meaning
Number of currently logged in users
System load, that is, the average length of the task queue. The three values ​​are the average values ​​from 1 minute, 5 minutes, and 15 minutes ago to now.


Line 2: Tasks: 159 total, 1 running, 158 sleeping, 0 stopped, 0 zombie
Line 3: %Cpu(s): 37.0 us , 3.7 sy, 0.0 ni, 59.3 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
The 2nd and 3rd lines are process and CPU information When there are multiple CPUs, these contents may There will be more than two lines, and the parameters are as follows:

##ContentMeaning 159 totalTotal number of processes1 runningNumber of running processes158 sleepingNumber of sleeping processes0 stoppedNumber of stopped processes0 zombieNumber of zombie processes37.0 usCPU percentage occupied by user space3.7 syCPU percentage occupied by kernel space0.0 ni59.3 idIdle CPU percentage0.0 waPercentage of CPU time waiting for input and output0.0 hi0.0 si##0.0 stLine 4: KiB Mem: 1530752 total, 1481968 used, 48784 free, 70988 buffers
CPU percentage occupied by processes that have changed priorities in the user process space
Percentage of CPU occupied by Hardware IRQ
Percentage of CPU occupied by software interrupts
Line 5: KiB Swap: 3905532 total, 267544 used, 3637988 free . 617312 cached Mem

The 4th and 5th lines are memory information
The parameters are as follows:



##Content

MeaningKiB Mem: 1530752 totalTotal physical memory1481968 usedPhysical used Total memory48784 freeTotal free memory70988 buffers(buff/cache)Amount of memory used for kernel cacheKiB Swap: 3905532 totalTotal amount of swap area267544 used Total amount of swap area used3637988 freeTotal amount of free swap area617312 cached MemThe total amount of cached swap area. 3156100 avail MemRepresents the amount of physical memory available for the next allocation of the process

The total amount of the buffered swap area mentioned last is explained here. The so-called total buffered swap area means that the content in the memory is swapped out to the swap area, and then swapped into the memory, but the used The swap area has not been overwritten, and this value is the size of the swap area where these contents already exist in memory. When the corresponding memory is swapped out again, there is no need to write to the swap area.

There is an approximate formula for calculating the amount of available memory:
free on the fourth line buffers on the fourth line cached on the fifth line

2. Process information

Column name Meaning
PID Process id
PPID Parent process id
RUSER Real user name
UID User ID of the process owner
USER Username of the process owner
GROUP Group name of the process owner
TTY Terminal name for starting the process. Processes that are not started from the terminal are displayed as?
PR Priority
NI nice value. Negative values ​​indicate high priority, positive values ​​indicate low priority
P The last CPU used is only meaningful in a multi-CPU environment
%CPU CPU time usage percentage since last update
TIME Total CPU time used by the process , unit second
TIME Total CPU time used by the process, unit 1/100 second
%MEM Percentage of physical memory used by the process
VIRT The total amount of virtual memory used by the process, in kb. VIRT=SWAP RES
SWAP The size of the virtual memory used by the process that is swapped out, unit kb
RES The size of the physical memory used by the process and not swapped out, in kb. RES=CODE DATA
CODE The physical memory size occupied by the executable code, unit kb
DATA The physical memory size occupied by parts other than the executable code (data segment stack), unit kb
SHR Shared memory size, unit kb
nFLT Number of page errors
nDRT The page that has been modified since the last time it was written number.
S Process status. D=uninterruptible sleep state R=run S=sleep T=track/stop Z=zombie process
COMMAND Command name/command line
WCHAN If the process is sleeping, the name of the system function in sleep is displayed
Flags Task flag

Others

When entering top by default, the processes are sorted according to CPU usage.

1. In the top basic view, press the keyboard number "1" to monitor the status of each logical CPU:


2. Press the keyboard 'b' ( Turn on and off the highlighting effect) The top view changes as follows:

PID 16283 is the only running process in the current top view. You can also press 'y' on the keyboard to turn on or off the highlighting effect of running processes.

3. Press 'x' on the keyboard (turn on/off the highlighting effect of the sort column), the top view changes as follows:

You can see now It is sorted by "%CPU". You can press "shift >" or "shift

4. Change the process display field

In the top basic view, tap "f" to enter another view, where you can edit the display fields in the basic view:

Use the up and down keys to select an option, and press the space bar to decide whether to display this option in the basic view.

The top command is a very powerful function, but the smallest unit it monitors is a process. If you want to monitor a smaller unit, you need to use the ps or netstate command to meet our requirements.

Related recommendations: "Linux Video Tutorial"

The above is the detailed content of Detailed analysis of top command parameters in Linux. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:CSDN. If there is any infringement, please contact admin@php.cn delete
What is Maintenance Mode in Linux? ExplainedWhat is Maintenance Mode in Linux? ExplainedApr 22, 2025 am 12:06 AM

MaintenanceModeinLinuxisaspecialbootenvironmentforcriticalsystemmaintenancetasks.Itallowsadministratorstoperformtaskslikeresettingpasswords,repairingfilesystems,andrecoveringfrombootfailuresinaminimalenvironment.ToenterMaintenanceMode,interrupttheboo

Linux: A Deep Dive into Its Fundamental PartsLinux: A Deep Dive into Its Fundamental PartsApr 21, 2025 am 12:03 AM

The core components of Linux include kernel, file system, shell, user and kernel space, device drivers, and performance optimization and best practices. 1) The kernel is the core of the system, managing hardware, memory and processes. 2) The file system organizes data and supports multiple types such as ext4, Btrfs and XFS. 3) Shell is the command center for users to interact with the system and supports scripting. 4) Separate user space from kernel space to ensure system stability. 5) The device driver connects the hardware to the operating system. 6) Performance optimization includes tuning system configuration and following best practices.

Linux Architecture: Unveiling the 5 Basic ComponentsLinux Architecture: Unveiling the 5 Basic ComponentsApr 20, 2025 am 12:04 AM

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

Linux Operations: Utilizing the Maintenance ModeLinux Operations: Utilizing the Maintenance ModeApr 19, 2025 am 12:08 AM

Linux maintenance mode can be entered through the GRUB menu. The specific steps are: 1) Select the kernel in the GRUB menu and press 'e' to edit, 2) Add 'single' or '1' at the end of the 'linux' line, 3) Press Ctrl X to start. Maintenance mode provides a secure environment for tasks such as system repair, password reset and system upgrade.

Linux: How to Enter Recovery Mode (and Maintenance)Linux: How to Enter Recovery Mode (and Maintenance)Apr 18, 2025 am 12:05 AM

The steps to enter Linux recovery mode are: 1. Restart the system and press the specific key to enter the GRUB menu; 2. Select the option with (recoverymode); 3. Select the operation in the recovery mode menu, such as fsck or root. Recovery mode allows you to start the system in single-user mode, perform file system checks and repairs, edit configuration files, and other operations to help solve system problems.

Linux's Essential Components: Explained for BeginnersLinux's Essential Components: Explained for BeginnersApr 17, 2025 am 12:08 AM

The core components of Linux include the kernel, file system, shell and common tools. 1. The kernel manages hardware resources and provides basic services. 2. The file system organizes and stores data. 3. Shell is the interface for users to interact with the system. 4. Common tools help complete daily tasks.

Linux: A Look at Its Fundamental StructureLinux: A Look at Its Fundamental StructureApr 16, 2025 am 12:01 AM

The basic structure of Linux includes the kernel, file system, and shell. 1) Kernel management hardware resources and use uname-r to view the version. 2) The EXT4 file system supports large files and logs and is created using mkfs.ext4. 3) Shell provides command line interaction such as Bash, and lists files using ls-l.

Linux Operations: System Administration and MaintenanceLinux Operations: System Administration and MaintenanceApr 15, 2025 am 12:10 AM

The key steps in Linux system management and maintenance include: 1) Master the basic knowledge, such as file system structure and user management; 2) Carry out system monitoring and resource management, use top, htop and other tools; 3) Use system logs to troubleshoot, use journalctl and other tools; 4) Write automated scripts and task scheduling, use cron tools; 5) implement security management and protection, configure firewalls through iptables; 6) Carry out performance optimization and best practices, adjust kernel parameters and develop good habits.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software