Table of contents
top startup parameters
top
: Run the basic top command to display all process information, refresh every 5 seconds, and sort according to the usage percentage %CPUtop -c
: show the entire command line instead of the entire command nametop -d secs
: Indicates the process interface update time (5 seconds by default)top -n max
: the number of times to cycle through the displaytop -u|U user
: Specify username informationtop -p pid(s)
: View the specified process informationtop -b
: Batch file mode, used together with the "n" parameter, can be used to output the results of top to a filetop -o field
: According to which column to sort, such as sorting according to memorytop -o %MEM
(top uses cpu to sort by default)top -w [cols]
: Display the details of a columntop -q
:top is refreshed without any delay.top -S
: Specifies the accumulation modetop -s
: Make the top command run in safe mode. Potential dangers posed by interactive commands will be removed.top -i
: Make top not show any idle or dead processes.top -b -n 2 > /tmp/top.txt
: Indicates that the process table with PID 2 is printed twice in /tmp/top.txt.
Basic field description
The first line, system task statistics:
top - 16:55:08 up 194 days, 1:23, 1 user, load average: 0.00, 0.01, 0.05
16:55:08
- current system timeup 194 days, 1:23
- The system has been running for 194 days, 1 hour and 23 minutes (no reboot during this period)1 user
- There is currently a user logged into the systemload average: 0.00, 0.01, 0.05
- The latter three are the average system load from 1 minute, 5 minutes, and 15 minutes ago to the present, and the converted percentages are 0%, 1%, and 5%.
The second line, process statistics:
Tasks: 75 total, 1 running, 74 sleeping, 0 stopped, 0 zombie
Tasks (processes): There are currently 75 processes in the system, of which 1 is running, 74 are dormant, 0 are in the stopped state, and 0 are in the zombie state
X total
: total number of processesX running
: number of running processesX sleeping
: Number of sleeping processesX stopped
: number of processes stoppedX zombie
: number of zombie processes
The third line, CPU statistics:
%Cpu(s): 1.0 us, 0.7 sy, 0.0 ni, 98.3 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
CPU usage percentage: 1% for user, 0.7% for kernel, 0.0% for process with changed priority, 98.3% for idle, 0.0% for IO waiting, 0.0% for hard interrupt, 0.0% for soft interrupt, stolen 0.0% of
X us
: The percentage of CPU consumed by the user mode processX sy
: Percentage of CPU consumed by the kernelX ni
: Percentage of CPU occupied by processes whose priority has been changed in the user process spaceX id
: Percentage of idle CPUX wa
: CPU percentage consumed by IO read and write waitingX hi
: CPU percentage consumed by hardware interrupts (Hardware IRQ)X si
: CPU percentage consumed by soft interrupts (Software IRQ)X st
: Stolen CPU percentage
Note:
IRQ: The full name of IRQ is Interrupt Request, which means "interrupt request".
st: Abbreviation of stole time, this indicator is only valid for virtual machines, indicating the percentage of CPU time allocated to the current virtual machine that is stolen by other virtual machines on the same physical machine
The fourth line, memory statistics:
KiB Mem : 1883724 total, 78476 free, 623420 used, 1181828 buff/cache
Memory/KIB: The total amount of physical memory is 1883724kib=1.796G, the free memory is 78476kib=76M, the memory in use is 623420kib=608M, and the amount of cached memory is 1181828kib=1.127G: Total physical memory - total memory
X kib total
in
X kib used
use
X kib free
- Total free memory
Xkib buff/cache
- Amount of cached memory
The fifth line, swap swap partition statistics:
KiB Swap: 0 total, 0 free, 0 used. 1055252 avail Mem
Swap partition/KiB: the total amount of swap area is 0, the total amount of free swap area is 0, the total amount of used swap area is 0, and the total amount of available swap area is 1055252Kib=1.006G - total amount of swap area - total amount of swap
X kib total
area
X kib used
used Amount
X kib free
- Total Free Swap
X kib avail Mem
- Total Available Swap
Note:
For memory monitoring, you must always monitor the used of the swap partition on the fifth line in top. If this value is constantly changing, it means that the kernel is constantly exchanging data between memory and swap, which means that the memory is not enough.
The sixth line, process information
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
PID
: process idUSER
: process ownerPR
: Process priorityNI
: nice value. Negative values indicate high priority, positive values indicate low priorityVIRT
: virtual memory usage Virtual memory
1. The virtual memory size "needed" by the process, including the library, code, data, etc. used by the process. 2.
If the process applies for 100m of memory, but actually only uses 10m, then it will increase by 100m, and not actual usageRES
: resident memory usage resident memory
1. The memory size currently used by the process, but not including swap out
2. Including the sharing of other processes
3. If you apply for 100m of memory and actually use 10m, it will only increase by 10m, contrary to VIRT
4. Regarding the memory occupied by the library, it only counts the memory size occupied by the loaded library filesSHR
: shared memory Shared memory
1. In addition to the shared memory of its own process, it also includes the shared memory of other processes
2. Although the process only uses a few functions of the shared library, it includes the size of the entire shared library
3. Calculate a certain process The physical memory size formula: RES – SHR
4, after swap out, it will drop downDATA
1. The memory occupied by the data. If top is not displayed, press the f key to display it.
2. The real data space required by the program is actually used during operation.S
: Process status. D=uninterruptible sleep R=running S=sleep T=trace/stop Z=zombie process%CPU
: The percentage of CPU time occupied since the last update%MEM
: Percentage of physical memory used by the processTIME+
: The total CPU time used by the process, unit 1/100 secondCOMMAND
: process name (command name/command line)
control interface display
In the top running interface, press the following buttons (case sensitive):
1
– Show all CPU usages
– Change the screen update frequencyl
– Turn off or turn on the display of top information on the first linet
– Turn off or turn on the second line of Tasks and the third line of Cpus information displaym
– Turn off or turn on the display of the fourth line of Mem and the fifth line of Swap informationN
– Arrange the process list in the order of PID sizeP
– Sort the process list in order of CPU usageM
– Arrange the process list in order of memory usageh
– show helpn
– Set the number of processes displayed in the process listq
– exit top
Add undisplayed fields
By default, only the important PID, USER, PR, NI, VIRT, RES, SHR, S, %CPU, %MEM, TIME+, COMMAND columns are displayed. You can use the following shortcut keys to change the display content: after
pressing the key , and press the key . Example: 1. Enter the interface where the top command is running 2. Press 3. Move the mouse to PPID (parent process id) 4. Press the button to select, and the number will be displayed on the front after selection 5. Press the button to exit, and you can see that PPID is added behind Listf
空格
Esc
f
空格
PPUD
*
Esc
Detailed field description
Process thread:
PID
: process idPPID
: parent process idPGRP
: process group idPR
: Process priorityTPGID
: Tty process group idTGID
: thread group idWCHAN
: If the process is sleeping, display the name of the system function in sleep
User related :
UID
: The user id of the process owner (that is, the displayed identity may not be the real identity)USER
: The username of the process ownerRUID
: real user idRUSER
: real user nameSUID
: saved user idSUSER
: saved usernameGID
: effective user group idGROUP
: The group name of the process ownerSID
: session id (that is, it can be said to be a user session, or a session of a process)CGROUPS
: control groupSUPGIDS
: support group ID
Memory resources:
CODE
: The physical memory size occupied by the executable code, in kbDATA
: The size of physical memory occupied by parts other than executable code (data segment + stack), in kbRES
: The physical memory size used by the process and not swapped out, in kb. RES=CODE+DATA, corresponding to the %MEM column.SHR
: Shared memory or library size. unit kbSWAP
: The swapped-out size of the virtual memory used by the process, in kb.USED
: RES + SWAP size, unit kb.VIRT
: The total amount of virtual memory used by the process, in kb. VIRT=SWAP+RES
CPU resources:
TIME
: The total CPU time used by the process, in secondsTIME+
: The total CPU time used by the process, the unit is 1/100 second, for example, the format of the CPU time corresponding to 5:29.38 is: minutes:seconds.hundredths%CPU
: CPU usageP
: The last CPU used, only meaningful in a multi-CPU environment
characteristic:
S
: Process status. (D=uninterruptible sleep state, R=running, S=sleep, T=trace/stop, Z=zombie process)NI
: Nice value friendliness, negative value means high priority, positive value means low priorityCOMMAND
: process name or command line started (switched by c command)ENVIRON
:environment variableTTY
: The name of the terminal that started the process. Processes not started from a terminal are displayed as ?
Statistical data:
nTH
: Number of Threads number of threadsnDRT
: The number of pages that have been modified since the last writenFLT
: number of page faultsnMaj
: The requested memory page has not been loaded yet, this is the request generated by the main application memory applicationnMin
: The memory page is loaded but not managed by the MMUnamespace
: as a means of resource isolation for a group of processesnsIPC
: IIPC namespace, used to isolate IPCnsMNT
: for isolating mount pointsnsNET
: Used to isolate the network stacknsPID
: used to isolate the process numbernsUSER
: Used to isolate usersnsUTS
: Used to isolate domain name and hostnameFlags
: task flag, refer to sched.hvMj
: major page fault count incrementvMn
: minor page fault count increment