Linux Command top Command, linux Command top
Preface
The top command allows you to dynamically view the overall running status of the system in real time. It is a practical tool that combines the performance and running information of multiple parties to monitor the system. It also provides an interactive interface for use.
Syntax
top -hv | -bcHiOSs -d secs -n max -u|U user -p pid(s) -o field -w [cols]
Option
-B: Batch display results. Each time a refresh is performed, it is in the form of an append, rather than an overwrite.
-C: displays the complete command.
Example:
-H: displays the thread information corresponding to the process, which is used with-p/-P. The preceding example contains.
-I: make top not show how to idle or zombie processes.
-O: Options for output top:
wuzm@ubuntu:~$ top -O PIDPPIDUIDUSERRUIDRUSERSUIDSUSERGIDGROUPPGRPTTYTPGIDSIDPRNInTHP%CPUTIMETIME+%MEMVIRTSWAPRESCODEDATASHRnMajnMinnDRTSCOMMANDWCHANFlagsCGROUPSSUPGIDSSUPGRPSTGIDENVIRONvMjvMnUSEDnsIPCnsMNTnsNETnsPIDnsUSERnsUTS
-S: enables top to run in security mode to avoid potential risks caused by interactive commands.
-S: indicates the accumulative mode.
-D secs: interval between top interactive mode refresh
-U | U user: only the services enabled by the corresponding user are displayed.
-P pid (s): Specifies the process pid and only monitors the corresponding service.
-O field: sorts by corresponding column.For example, sort by pid as follows:
-W [col]: I do not know what to use yet...
Field parsing:
wuzm@ubuntu:~$ top -o PID -n 1top - 23:45:38 up 20:35, 1 user, load average: 0.27, 0.19, 0.13Tasks: 227 total, 1 running, 226 sleeping, 0 stopped, 0 zombie%Cpu(s): 11.0 us, 1.7 sy, 0.1 ni, 85.6 id, 0.5 wa, 0.0 hi, 1.2 si, 0.0 stKiB Mem : 2018052 total, 108948 free, 1417864 used, 491240 buff/cacheKiB Swap: 1046524 total, 677372 free, 369152 used. 355252 avail Mem
1. top-23:45:38 [current system time]
2. up [system and 16 days of operation]
3. 1 user [1. One user currently logged on]
4. load average: 0.27, 0.19, 0.13 [average length of System assistance and task queue. The three values are the average values from 1 minute, 5 minutes, and 15 minutes ago to the present]
5. Tasks: 227 total [the total number of processes is 227]
6. 1 running [The number of running processes is 1]
7. 226 sleeping [The number of sleeping processes is 226]
8. 0 stopped: the number of stopped processes is 0]
9. 0 zombie [0 zombie processes]
10.% Cpu (s): 11.0 us, 1.7 sy, 0.1 ni, 85.6 id, 0.5 wa, 0.0 hi, 1.2 si, 0.0 st
【
11.0% us, CPU usage percentage of user space
1.7% sy, CPU usage in kernel space
0.1% ni: CPU usage of processes with a higher priority in the process space
85.6% id, percentage of idle CPU
0.5% wa, CPU time percentage waiting for Input and Output
0.0% hi, percentage of hardware CPU interruptions
1.2% si, percentage of Soft Interrupt occupied
0.0% st, Vm usage percentage
]
KiB Mem: 2018052 total, 108948 free, 1417864 used, 491240 buff/cache
【
Unit: KB
2018052 total, total physical memory
108948 free, total idle memory
1417864 used, total memory used
491240 buff/cache, used as the memory size of the kernel cache
]
KiB Swap: 1046524 total, 677372 free, 369152 used. 355252 avail Mem
【
Unit: KB
1046524 total, total number of swap Areas
369152 used, the total number of swap areas used
677372 free, total number of idle swap Areas
355252 avail Mem, the total number of buffer swap areas, the memory content is swapped out to the swap area, and then into the memory, but the size of the swap area in the used swap area, if the corresponding memory is swapped out again, you do not need to write data to the swap zone.
]
Parse some fields:
* PID = Process Id nsUSER = USER namespace Inode
* USER = valid tive User Name nsUTS = UTS namespace Inode
* PR = Priority
* NI = Nice Value
* VIRT = Virtual Image (KiB)
* RES = Resident Size (KiB)
* SHR = Shared Memory (KiB)
* S = Process Status
* % CPU = CPU Usage
* % MEM = Memory Usage (RES)
* TIME + = CPU Time, hundredths
* COMMAND = Command Name/Line
PPID = Parent Process pid
UID = valid tive User Id
RUID = Real User Id
RUSER = Real User Name
SUID = Saved User Id
SUSER = Saved User Name
GID = Group Id
GROUP = Group Name
PGRP = Process Group Id
TTY = Controlling Tty
TPGID = Tty Process Grp Id
SID = Session Id
NTH = Number of Threads
P = Last Used Cpu (SMP)
TIME = CPU Time
SWAP = Swapped Size (KiB)
CODE = Code Size (KiB)
DATA = Data + Stack (KiB)
NMaj = Major Page Faults
NMin = Minor Page Faults
Mcm t = Dirty Pages Count
WCHAN = Sleeping in Function
Flags = Task Flags