


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.
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:
Content | Meaning |
---|---|
represents the current time | |
The system running time format is hours: minutes | |
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:
1 running | |
158 sleeping | |
0 stopped | |
0 zombie | |
37.0 us | |
3.7 sy | |
CPU percentage occupied by processes that have changed priorities in the user process space | 59.3 id |
0.0 wa | |
Percentage of CPU occupied by Hardware IRQ | |
Percentage of CPU occupied by software interrupts | ##0.0 st |
Line 4: KiB Mem: 1530752 total, 1481968 used, 48784 free, 70988 buffers |
The 4th and 5th lines are memory information
The parameters are as follows:
##Content
KiB Mem: 1530752 total | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1481968 used | Physical used Total memory | |||||||||||||||||||||||||||||||||||||||||||||||||||||
48784 free | Total free memory | |||||||||||||||||||||||||||||||||||||||||||||||||||||
70988 buffers(buff/cache) | Amount of memory used for kernel cache | |||||||||||||||||||||||||||||||||||||||||||||||||||||
KiB Swap: 3905532 total | Total amount of swap area | |||||||||||||||||||||||||||||||||||||||||||||||||||||
267544 used | Total amount of swap area used | |||||||||||||||||||||||||||||||||||||||||||||||||||||
3637988 free | Total amount of free swap area | |||||||||||||||||||||||||||||||||||||||||||||||||||||
617312 cached Mem | The total amount of cached swap area. | |||||||||||||||||||||||||||||||||||||||||||||||||||||
3156100 avail Mem | Represents the amount of physical memory available for the next allocation of the process | |||||||||||||||||||||||||||||||||||||||||||||||||||||
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!

MaintenanceModeinLinuxisaspecialbootenvironmentforcriticalsystemmaintenancetasks.Itallowsadministratorstoperformtaskslikeresettingpasswords,repairingfilesystems,andrecoveringfrombootfailuresinaminimalenvironment.ToenterMaintenanceMode,interrupttheboo

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.

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 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.

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.

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.

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.

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.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

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