12:38:33 |
當(dāng)前時(shí)間 |
up 50days |
系統(tǒng)運(yùn)行時(shí)間,格式為時(shí):分 |
1 user |
當(dāng)前登錄用戶數(shù) |
load average: 0.06, 0.60, 0.48 |
系統(tǒng)負(fù)載,即任務(wù)隊(duì)列的平均長(zhǎng)度。 三個(gè)數(shù)值分別為 1分鐘、5分鐘、15分鐘前到現(xiàn)在的平均值。 |
2. 第二、三行為進(jìn)程和CPU的信息
當(dāng)有多個(gè)CPU時(shí),這些內(nèi)容可能會(huì)超過(guò)兩行。內(nèi)容如下:
Tasks: 29 total |
進(jìn)程總數(shù) |
1 running |
正在運(yùn)行的進(jìn)程數(shù) |
28 sleeping |
睡眠的進(jìn)程數(shù) |
0 stopped |
停止的進(jìn)程數(shù) |
0 zombie |
僵尸進(jìn)程數(shù) |
Cpu(s): 0.3% us |
用戶空間占用CPU百分比 |
1.0% sy |
內(nèi)核空間占用CPU百分比 |
0.0% ni |
用戶進(jìn)程空間內(nèi)改變過(guò)優(yōu)先級(jí)的進(jìn)程占用CPU百分比 |
98.7% id |
空閑CPU百分比 |
0.0% wa |
等待輸入輸出的CPU時(shí)間百分比 |
0.0% hi |
|
0.0% si |
3. 第四五行為內(nèi)存信息。
內(nèi)容如下:
Mem: 191272k total |
物理內(nèi)存總量 |
173656k used |
使用的物理內(nèi)存總量 |
17616k free |
空閑內(nèi)存總量 |
22052k buffers |
用作內(nèi)核緩存的內(nèi)存量 |
Swap: 192772k total |
交換區(qū)總量 |
0k used |
使用的交換區(qū)總量 |
192772k free |
空閑交換區(qū)總量 |
123988k cached |
緩沖的交換區(qū)總量。 內(nèi)存中的內(nèi)容被換出到交換區(qū),而后又被換入到內(nèi)存,但使用過(guò)的交換區(qū)尚未被覆蓋, 該數(shù)值即為這些內(nèi)容已存在于內(nèi)存中的交換區(qū)的大小。相應(yīng)的內(nèi)存再次被換出時(shí)可不必再對(duì)交換區(qū)寫(xiě)入。 |
二. 進(jìn)程信息
列名 |
含義 |
PID |
進(jìn)程id |
PPID |
父進(jìn)程id |
RUSER |
Real user name |
UID |
進(jìn)程所有者的用戶id |
USER |
進(jìn)程所有者的用戶名 |
GROUP |
進(jìn)程所有者的組名 |
TTY |
啟動(dòng)進(jìn)程的終端名。不是從終端啟動(dòng)的進(jìn)程則顯示為 ? |
PR |
優(yōu)先級(jí) |
NI |
nice值。負(fù)值表示高優(yōu)先級(jí),正值表示低優(yōu)先級(jí) |
P |
最后使用的CPU,僅在多CPU環(huán)境下有意義 |
%CPU |
上次更新到現(xiàn)在的CPU時(shí)間占用百分比 |
TIME |
進(jìn)程使用的CPU時(shí)間總計(jì),單位秒 |
TIME+ |
進(jìn)程使用的CPU時(shí)間總計(jì),單位1/100秒 |
%MEM |
進(jìn)程使用的物理內(nèi)存百分比 |
VIRT |
進(jìn)程使用的虛擬內(nèi)存總量,單位kb。VIRT=SWAP+RES |
SWAP |
進(jìn)程使用的虛擬內(nèi)存中,被換出的大小,單位kb。 |
RES |
進(jìn)程使用的、未被換出的物理內(nèi)存大小,單位kb。RES=CODE+DATA |
CODE |
可執(zhí)行代碼占用的物理內(nèi)存大小,單位kb |
DATA |
可執(zhí)行代碼以外的部分(數(shù)據(jù)段+棧)占用的物理內(nèi)存大小,單位kb |
SHR |
共享內(nèi)存大小,單位kb |
nFLT |
頁(yè)面錯(cuò)誤次數(shù) |
nDRT |
最后一次寫(xiě)入到現(xiàn)在,被修改過(guò)的頁(yè)面數(shù)。 |
S |
進(jìn)程狀態(tài)。 |
COMMAND |
命令名/命令行 |
WCHAN |
若該進(jìn)程在睡眠,則顯示睡眠中的系統(tǒng)函數(shù)名 |
Flags |
任務(wù)標(biāo)志,參考 sched.h |
top 的man 命令解釋如下:
Listed below are top's available fields. They are always associated with the letter shown, regardless of the position you may have established for them with the 'o' (Order fields) interactive command.Any field is selectable as the sort field, and you control whether they are sorted high-to-low or low-to-high. For additional information on sort provisions see topic 3c. TASK Area Commands.
a: PID -- Process Id
The task's unique process ID, which periodically wraps, though never restarting at zero.
b: PPID -- Parent Process Pid
The process ID of a task's parent.
c: RUSER -- Real User Name
The real user name of the task's owner.
d: UID -- User Id
The effective user ID of the task's owner.
e: USER -- User Name
The effective user name of the task's owner.
f: GROUP -- Group Name
The effective group name of the task's owner.
g: TTY -- Controlling Tty
The name of the controlling terminal. This is usually the device (serial port, pty, etc.) from which the process was started, and which it uses for input oroutput. However, a task need not be associated with a terminal, in which case you'll see '?' displayed.
h: PR -- Priority
The priority of the task.
i: NI -- Nice value
The nice value of the task. A negative nice value means higher priority, whereas a positive nice value means lower priority. Zero in this field simply means priority will not be adjusted in determining a task's dispatchability.
j: P -- Last used CPU (SMP)
A number representing the last used processor. In a true SMP environment this will likely change frequently since the kernel intentionally uses weak affinity. Also, the very act of running top may break this weak affinity and cause more processes to change CPUs more often (because of the extra demand for cpu time).
k: %CPU -- CPU usage
The task's share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time. In a true SMP environment, if 'Irix mode' is Off, top will operate in 'Solaris mode' where a task's cpu usage will be divided by the total number of CPUs. You toggle 'Irix/Solaris' modes with the 'I' interactive command.
l: TIME -- CPU Time
Total CPU time the task has used since it started. When 'Cumulative mode' is On, each process is listed with the cpu time that it and its dead children has used. You toggle 'Cumulative mode' with 'S', which is a command-line option and an interactive command. See the 'S' interactive command for additional information regarding this mode.
m: TIME+ -- CPU Time, hundredths
The same as 'TIME', but reflecting more granularity through hundredths of a sec ond.
n: %MEM -- Memory usage (RES)
A task's currently used share of available physical memory.
o: VIRT -- Virtual Image (kb)
The total amount of virtual memory used by the task. It includes all code, data and shared libraries plus pages that have been swapped out. (Note: you can define the STATSIZE=1 environment variable and the VIRT will be calculated from the /proc/#/state VmSize field.)
VIRT = SWAP + RES.
p: SWAP -- Swapped size (kb)
The swapped out portion of a task's total virtual memory image.
q: RES -- Resident size (kb)
The non-swapped physical memory a task has used.
RES = CODE + DATA.
r: CODE -- Code size (kb)
The amount of physical memory devoted to executable code, also known as the'text resident set' size or TRS.
s: DATA -- Data+Stack size (kb)
The amount of physical memory devoted to other than executable code, also known the 'data resident set' size or DRS.
t: SHR -- Shared Mem size (kb)
The amount of shared memory used by a task. It simply reflects memory that could be potentially shared with other processes.
u: nFLT -- Page Fault count
The number of major page faults that have occurred for a task. A page fault occurs when a process attempts to read from or write to a virtual page that is not currently present in its address space. A major page fault is when disk access is involved in making that page available.
v: nDRT -- Dirty Pages count
The number of pages that have been modified since they were last written to disk. Dirty pages must be written to disk before the corresponding physical memory location can be used for some other virtual page.
w: S -- Process Status
The status of the task which can be one of:
'D' = uninterruptible sleep
'R' = running
'S' = sleeping
'T' = traced or stopped
'Z' = zombie
Tasks shown as running should be more properly thought of as 'ready to run' --their task_struct is simply represented on the Linux run-queue. Even without a true SMP machine, you may see numerous tasks in this state depending on top's delay interval and nice value.
x: Command -- Command line or Program name
Display the command line used to start a task or the name of the associated program. You toggle between command line and name with 'c', which is both a command-line option and an interactive command. When you've chosen to display command lines, processes without a command line (like kernel threads) will be shown with only the program name in parentheses, as in this example: ( mdrecoveryd ) Either form of display is subject to potential truncation if it's too long to fit in this field's current width. That width depends upon other fields selected, their order and the current screen width.
Note: The 'Command' field/column is unique, in that it is not fixed-width. When displayed, this column will be allocated all remaining screen width (up to the maximum 512 characters) to provide for the potential growth of program names into command lines.
y: WCHAN -- Sleeping in Function
Depending on the availability of the kernel link map ('System.map'), this field will show the name or the address of the kernel function in which the task is currently sleeping. Running tasks will display a dash ('-') in this column.
Note: By displaying this field, top's own working set will be increased by over 700Kb. Your only means of reducing that overhead will be to stop and restart top.
z: Flags -- Task Flags
This column represents the task's current scheduling flags which are expressed in hexadecimal notation and with zeros suppressed. These flags are officially documented in linux/sched.h>. Less formal documentation can also be found on the 'Fields select' and 'Order fields' screens.
默認(rèn)情況下僅顯示比較重要的 PID、USER、PR、NI、VIRT、RES、SHR、S、%CPU、%MEM、TIME+、COMMAND 列。
2.1 用快捷鍵更改顯示內(nèi)容。
(1)更改顯示內(nèi)容通過(guò) f鍵可以選擇顯示的內(nèi)容。
按 f 鍵之后會(huì)顯示列的列表,按 a-z 即可顯示或隱藏對(duì)應(yīng)的列,最后按回車(chē)鍵確定。
(2)按o鍵可以改變列的顯示順序。
按小寫(xiě)的 a-z 可以將相應(yīng)的列向右移動(dòng),而大寫(xiě)的 A-Z 可以將相應(yīng)的列向左移動(dòng)。最后按回車(chē)鍵確定。
按大寫(xiě)的 F 或 O 鍵,然后按 a-z 可以將進(jìn)程按照相應(yīng)的列進(jìn)行排序。而大寫(xiě)的 R 鍵可以將當(dāng)前的排序倒轉(zhuǎn)。
設(shè)置完按回車(chē)返回界面。
三. 命令使用
詳細(xì)內(nèi)容可以參考MAN 幫助文檔。這里列舉部分內(nèi)容:
命令格式:
top [-] [d] [p] [q] [c] [C] [S] [n]
參數(shù)說(shuō)明:
d: 指定每?jī)纱纹聊恍畔⑺⑿轮g的時(shí)間間隔。當(dāng)然用戶可以使用s交互命令來(lái)改變之。
p: 通過(guò)指定監(jiān)控進(jìn)程ID來(lái)僅僅監(jiān)控某個(gè)進(jìn)程的狀態(tài)。
q:該選項(xiàng)將使top沒(méi)有任何延遲的進(jìn)行刷新。如果調(diào)用程序有超級(jí)用戶權(quán)限,那么top將以盡可能高的優(yōu)先級(jí)運(yùn)行。
S: 指定累計(jì)模式
s : 使top命令在安全模式中運(yùn)行。這將去除交互命令所帶來(lái)的潛在危險(xiǎn)。
i: 使top不顯示任何閑置或者僵死進(jìn)程。
c: 顯示整個(gè)命令行而不只是顯示命令名
在top命令的顯示窗口,我們還可以輸入以下字母,進(jìn)行一些交互:
幫助文檔如下:
Help for Interactive Commands - procps version 3.2.7
Window 1:Def: Cumulative mode Off. System: Delay 4.0 secs; Secure mode Off.
Z,B Global: 'Z' change color mappings; 'B' disable/enable bold
l,t,m Toggle Summaries: 'l' load avg; 't' task/cpu stats; 'm' mem info
1,I Toggle SMP view: '1' single/separate states; 'I' Irix/Solaris mode
f,o . Fields/Columns: 'f' add or remove; 'o' change display order
F or O . Select sort field
,> . Move sort field: '' next col left; '>' next col right
R,H . Toggle: 'R' normal/reverse sort; 'H' show threads
c,i,S . Toggle: 'c' cmd name/line; 'i' idle tasks; 'S' cumulative time
x,y . Toggle highlights: 'x' sort field; 'y' running tasks
z,b . Toggle: 'z' color/mono; 'b' bold/reverse (only if 'x' or 'y')
u . Show specific user only
n or # . Set maximum tasks displayed
k,r Manipulate tasks: 'k' kill; 'r' renice
d or s Set update interval
W Write configuration file
q Quit
( commands shown with '.' require a visible task display window )
Press 'h' or '?' for help with Windows,
h或者? : 顯示幫助畫(huà)面,給出一些簡(jiǎn)短的命令總結(jié)說(shuō)明。
k :終止一個(gè)進(jìn)程。系統(tǒng)將提示用戶輸入需要終止的進(jìn)程PID,以及需要發(fā)送給該進(jìn)程什么樣的信號(hào)。一般的終止進(jìn)程可以使用15信號(hào);如果不能正常結(jié)束那就使用信號(hào)9強(qiáng)制結(jié)束該進(jìn)程。默認(rèn)值是信號(hào)15。在安全模式中此命令被屏蔽。
i:忽略閑置和僵死進(jìn)程。這是一個(gè)開(kāi)關(guān)式命令。
q: 退出程序。
r: 重新安排一個(gè)進(jìn)程的優(yōu)先級(jí)別。系統(tǒng)提示用戶輸入需要改變的進(jìn)程PID以及需要設(shè)置的進(jìn)程優(yōu)先級(jí)值。輸入一個(gè)正值將使優(yōu)先級(jí)降低,反之則可以使該進(jìn)程擁有更高的優(yōu)先權(quán)。默認(rèn)值是10。
S:切換到累計(jì)模式。
s : 改變兩次刷新之間的延遲時(shí)間。系統(tǒng)將提示用戶輸入新的時(shí)間,單位為s。如果有小數(shù),就換算成ms。輸入0值則系統(tǒng)將不斷刷新,默認(rèn)值是5 s。需要注意的是如果設(shè)置太小的時(shí)間,很可能會(huì)引起不斷刷新,從而根本來(lái)不及看清顯示的情況,而且系統(tǒng)負(fù)載也會(huì)大大增加。
f或者F :從當(dāng)前顯示中添加或者刪除項(xiàng)目。
o或者O :改變顯示項(xiàng)目的順序。
l: 切換顯示平均負(fù)載和啟動(dòng)時(shí)間信息。即顯示影藏第一行
m: 切換顯示內(nèi)存信息。即顯示影藏內(nèi)存行
t : 切換顯示進(jìn)程和CPU狀態(tài)信息。即顯示影藏CPU行
c: 切換顯示命令名稱和完整命令行。 顯示完整的命令。 這個(gè)功能很有用。
M : 根據(jù)駐留內(nèi)存大小進(jìn)行排序。
P:根據(jù)CPU使用百分比大小進(jìn)行排序。
T: 根據(jù)時(shí)間/累計(jì)時(shí)間進(jìn)行排序。
W: 將當(dāng)前設(shè)置寫(xiě)入~/.toprc文件中。這是寫(xiě)top配置文件的推薦方法。
標(biāo)簽:北海 遼陽(yáng) 淘寶邀評(píng) 眉山 延邊 南陽(yáng) 龍巖 大興安嶺
巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Linux Top 命令解析 比較詳細(xì)》,本文關(guān)鍵詞 Linux,Top,命令,解析,比較,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。