]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.bin/top/top.1
MFV: less v643.
[FreeBSD/FreeBSD.git] / usr.bin / top / top.1
1 .\" $FreeBSD$
2 .Dd November 18, 2021
3 .Dt TOP 1
4 .Os
5 .Sh NAME
6 .Nm top
7 .Nd display and update information about the top cpu processes
8 .Sh SYNOPSIS
9 .Nm
10 .Op Fl abCHIijnPpqSTtuvxz
11 .Op Fl d Ar count
12 .Op Fl J Ar jail
13 .Op Fl m Ar mode
14 .Op Fl o Ar field
15 .Op Fl p Ar pid
16 .Op Fl s Ar time
17 .Op Fl U Ar uid
18 .Op Ar number
19 .Sh DESCRIPTION
20 .Nm
21 displays the top
22 processes on the system and periodically updates this information.
23 If standard output is an intelligent terminal (see below) then
24 as many processes as will fit on the terminal screen are displayed
25 by default.
26 Otherwise, a good number of them are shown (around 20).
27 Raw cpu percentage is used to rank the processes.
28 If
29 .Ar number
30 is given, then the top
31 .Ar number
32 processes will be displayed instead of the default.
33 .Pp
34 .Nm
35 makes a distinction between terminals that support advanced capabilities
36 and those that do not.
37 This distinction affects the choice of defaults for certain options.
38 In the remainder of this document, an
39 .Dq intelligent
40 terminal is one that
41 supports cursor addressing, clear screen, and clear to end of line.
42 Conversely, a
43 .Dq dumb
44 terminal is one that does not support such
45 features.
46 If the output of
47 .Nm
48 is redirected to a file, it acts as if it were being run on a dumb
49 terminal.
50 .Pp
51 The options are as follows:
52 .Bl -tag -width indent
53 .It Fl a
54 Display command names derived from the argv[] vector, rather than real
55 executable name.
56 It it useful when you want to watch applications, that
57 puts their status information there.
58 If the real name differs from argv[0],
59 it will be displayed in parenthesis.
60 Non-printable characters in the command line are
61 encoded in C-style backslash sequences or
62 a three digit octal sequences.
63 .It Fl b
64 Use
65 .Dq batch
66 mode.
67 In this mode, all input from the terminal is
68 ignored.
69 Interrupt characters (such as ^C and ^\e) still have an effect.
70 This is the default on a dumb terminal, or when the output is not a terminal.
71 .It Fl C
72 Toggle CPU display mode.
73 By default top displays the weighted CPU percentage in the WCPU column
74 (this is the same value that
75 .Xr ps 1
76 displays as CPU).
77 Each time
78 .Fl C
79 flag is passed it toggles between
80 .Dq raw cpu
81 mode and
82 .Dq weighted cpu
83 mode, showing the
84 .Dq CPU
85 or the
86 .Dq WCPU
87 column respectively.
88 .It Fl d Ar count
89 Show only
90 .Ar count
91 displays, then exit.
92 A display is considered to be one update of the
93 screen.
94 The default is 1 for dumb terminals.
95 Note that for
96 .Ar count
97 = 1
98 no information is available about the percentage of time spent by the CPU in every state.
99 .It Fl H
100 Display each thread for a multithreaded process individually.
101 By default a single summary line is displayed for each process.
102 .It Fl I
103 Do not display idle processes.
104 By default, top displays both active and idle processes.
105 .It Fl i
106 Use
107 .Dq interactive
108 mode.
109 In this mode, any input is immediately
110 read for processing.
111 See the section on
112 .Dq Interactive Mode
113 for an explanation of
114 which keys perform what functions.
115 After the command is processed, the
116 screen will immediately be updated, even if the command was not
117 understood.
118 This mode is the default when standard output is an
119 intelligent terminal.
120 .It Fl J Ar jail
121 Show only those processes owned by
122 .Ar jail .
123 This may be either the
124 .Ar jid
125 or
126 .Ar name
127 of the jail.
128 Use
129 0
130 to limit to host processes.
131 Using this option implies
132 .Fl j .
133 .It Fl j
134 Display the
135 .Xr jail 8
136 ID.
137 .It Fl m Ar mode
138 Display statistics in the specified
139 .Ar mode .
140 Available modes are
141 .Cm cpu
142 and
143 .Cm io .
144 Default is
145 .Cm cpu .
146 .It Fl n
147 Use
148 .Dq non-interactive
149 mode.
150 This is identical to
151 .Dq batch
152 mode.
153 .It Fl o Ar field
154 Sort the process display area on the specified field.
155 The field name
156 is the name of the column as seen in the output, but in lower case:
157 .Dq cpu ,
158 .Dq size ,
159 .Dq res ,
160 .Dq time ,
161 .Dq pri ,
162 .Dq threads ,
163 .Dq total ,
164 .Dq read ,
165 .Dq write ,
166 .Dq fault ,
167 .Dq vcsw ,
168 .Dq ivcsw ,
169 .Dq jid ,
170 .Dq swap ,
171 or
172 .Dq pid .
173 .It Fl P
174 Display per-cpu CPU usage statistics.
175 .It Fl p Ar pid
176 Show only the process
177 .Ar pid .
178 .It Fl q
179 Renice
180 .Nm
181 to -20 so that it will run faster.
182 This can be used when the system is
183 being very sluggish to improve the possibility of discovering the problem.
184 This option can only be used by root.
185 .It Fl S
186 Show system processes in the display.
187 Normally, system processes such as the pager and the swapper are not shown.
188 This option makes them visible.
189 .It Fl s Ar time
190 Set the delay between screen updates to
191 .Ar time
192 seconds, which may be fractional.
193 The default delay between updates is 1 second.
194 .It Fl T
195 Toggle displaying thread ID (tid) instead of process id (pid).
196 .It Fl t
197 Do not display the
198 .Nm
199 process itself.
200 .It Fl U Ar username
201 Show only those processes owned by
202 .Ar username .
203 This option currently only accepts usernames and will not understand
204 uid numbers.
205 .It Fl u
206 Do not map uid numbers to usernames.
207 Normally,
208 .Nm
209 will read as much of the file
210 .Pa /etc/passwd
211 as is necessary to map
212 all the user id numbers it encounters into login names.
213 This option disables all that, while possibly decreasing execution time.
214 The uid numbers are displayed instead of the names.
215 .It Fl v
216 Write version number information to stderr then exit immediately.
217 .It Fl w
218 Display approximate swap usage for each process.
219 .It Fl z
220 Do not display the system idle process.
221 .El
222 .Pp
223 Both
224 .Ar count
225 and
226 .Ar number
227 fields can be specified as
228 .Dq infinite ,
229 indicating that they can
230 stretch as far as possible.
231 This is accomplished by using any proper
232 prefix of the keywords
233 .Dq infinity ,
234 .Dq maximum ,
235 or
236 .Dq all .
237 Boolean flags are toggles.
238 A second specification of any of these options will negate the first.
239 .Sh "INTERACTIVE MODE"
240 When
241 .Nm
242 is running in
243 .Dq interactive mode ,
244 it reads commands from the
245 terminal and acts upon them accordingly.
246 In this mode, the terminal is
247 put in
248 .Dq CBREAK ,
249 so that a character will be
250 processed as soon as it is typed.
251 Almost always, a key will be
252 pressed when
253 .Nm
254 is between displays; that is, while it is waiting for
255 .Ar time
256 seconds to elapse.
257 If this is the case, the command will be
258 processed and the display will be updated immediately thereafter
259 (reflecting any changes that the command may have specified).
260 This
261 happens even if the command was incorrect.
262 If a key is pressed while
263 .Nm
264 is in the middle of updating the display, it will finish the update and
265 then process the command.
266 Some commands require additional information,
267 and the user will be prompted accordingly.
268 While typing this information
269 in, the user's erase and kill keys (as set up by the command
270 .Xr stty 1 )
271 are recognized, and a newline terminates the input.
272 .Pp
273 These commands are currently recognized (^L refers to control-L):
274 .Bl -tag -width indent
275 .It ^L
276 Redraw the screen.
277 .It h
278 Display a summary of the commands (help screen).
279 Version information
280 is included in this display.
281 .It q
282 Quit
283 .Nm
284 .It d
285 Change the number of displays to show (prompt for new number).
286 Remember that the next display counts as one, so typing 'd1' will make
287 .Nm
288 show one final display and then immediately exit.
289 .It /
290 Display only processes that contain the specified string in their
291 command name.
292 If displaying arguments is enabled, the arguments are searched
293 too. '+' shows all processes.
294 .It m
295 Toggle the display between 'cpu' and 'io' modes.
296 .It n or #
297 Change the number of processes to display (prompt for new number).
298 .It s
299 Change the number of seconds to delay between displays
300 (prompt for new number).
301 .It S
302 Toggle the display of system processes.
303 .It a
304 Toggle the display of process titles.
305 .It k
306 Send a signal
307 .Pq SIGKILL by default
308 to a list of processes.
309 This acts similarly to the command
310 .Xr kill 1 .
311 .It r
312 Change the priority
313 .Pq the Dq nice
314 of a list of processes.
315 This acts similarly to
316 .Xr renice 8 .
317 .It u
318 Display only processes owned by a specific set of usernames (prompt for
319 username).
320 If the username specified is simply
321 .Dq +
322 or
323 .Dq - ,
324 then processes belonging to all users will be displayed.
325 Usernames can be added
326 to and removed from the set by prepending them with
327 .Dq +
328 and
329 .Dq - ,
330 respectively.
331 .It o
332 Change the order in which the display is sorted.
333 The sort key names include
334 .Dq cpu ,
335 .Dq res ,
336 .Dq size ,
337 and
338 .Dq time.
339 The default is cpu.
340 .It p
341 Display a specific process (prompt for pid).
342 If the pid specified is simply
343 .Dq + ,
344 then show all processes.
345 .It e
346 Display a list of system errors (if any) generated by the last
347 command.
348 .It H
349 Toggle the display of threads.
350 .It i or I
351 Toggle the display of idle processes.
352 .It j
353 Toggle the display of
354 .Xr jail 8
355 ID.
356 .It J
357 Display only processes owned by a specific jail (prompt for jail).
358 If the jail specified is simply
359 .Dq + ,
360 then processes belonging
361 to all jails and the host will be displayed.
362 This will also enable the display of JID.
363 .It P
364 Toggle the display of per-CPU statistics.
365 .It T
366 Toggle display of TID and PID
367 .It t
368 Toggle the display of the
369 .Nm
370 process.
371 .It w
372 Toggle the display of swap usage.
373 .It z
374 Toggle the display of the system idle process.
375 .El
376 .Sh "THE DISPLAY"
377 The top few lines of the display show general information
378 about the state of the system, including
379 the last process id assigned to a process (on most systems),
380 the three load averages,
381 the current time,
382 the number of existing processes,
383 the number of processes in each state
384 (sleeping, running, starting, zombies, and stopped),
385 and a percentage of time spent in each of the processor states
386 (user, nice, system, and idle).
387 It also includes information about physical and virtual memory allocation.
388 .Pp
389 The remainder of the screen displays information about individual
390 processes.
391 This display is similar in spirit to
392 .Xr ps 1
393 but it is not exactly the same.
394 PID is the process id,
395 JID, when displayed, is the
396 .Xr jail 8
397 ID corresponding to the process,
398 USERNAME is the name of the process's owner (if
399 .Fl u
400 is specified, a UID column will be substituted for USERNAME),
401 PRI is the current priority of the process,
402 NICE is the
403 .Xr nice 1
404 amount,
405 SIZE is the total size of the process (text, data, and stack),
406 RES is the current amount of resident memory,
407 SWAP is the approximate amount of swap, if enabled
408 (SIZE, RES and SWAP are given in kilobytes),
409 STATE is the current state (one of
410 .Dq START ,
411 .Dq RUN
412 (shown as
413 .Dq CPUn
414 on SMP systems),
415 .Dq SLEEP ,
416 .Dq STOP ,
417 .Dq ZOMB ,
418 .Dq WAIT ,
419 .Dq LOCK ,
420 or the event on which the process waits),
421 C is the processor number on which the process is executing
422 (visible only on SMP systems),
423 TIME is the number of system and user cpu seconds that the process has used,
424 WCPU, when displayed, is the weighted cpu percentage (this is the same
425 value that
426 .Xr ps 1
427 displays as CPU),
428 CPU is the raw percentage and is the field that is sorted to determine
429 the order of the processes, and
430 COMMAND is the name of the command that the process is currently running
431 (if the process is swapped out, this column is marked
432 .Dq <swapped> ) .
433 .Pp
434 If a process is in the
435 .Dq SLEEP
436 or
437 .Dq LOCK
438 state,
439 the state column will report the name of the event or lock on which the
440 process is waiting.
441 Lock names are prefixed with an asterisk
442 .Dq *
443 while sleep events
444 are not.
445 .Sh DESCRIPTION OF MEMORY
446 .Bd -literal
447 Mem: 61M Active, 86M Inact, 368K Laundry, 22G Wired, 102G Free
448 ARC: 15G Total, 9303M MFU, 6155M MRU, 1464K Anon, 98M Header, 35M Other
449      15G Compressed, 27G Uncompressed, 1.75:1 Ratio, 174M Overhead
450 Swap: 4096M Total, 532M Free, 13% Inuse, 80K In, 104K Out
451 .Ed
452 .Ss Physical Memory Stats
453 .Bl -tag -width "Uncompressed" -compact
454 .It Em Active
455 number of bytes active
456 .It Em Inact
457 number of clean bytes inactive
458 .It Em Laundry
459 number of dirty bytes queued for laundering
460 .It Em Wired
461 number of bytes wired down, including IO-level cached file data pages
462 .It Em Buf
463 number of bytes used for IO-level disk caching
464 .It Em Free
465 number of bytes free
466 .El
467 .Ss ZFS ARC Stats
468 These stats are only displayed when the ARC is in use.
469 .Pp
470 .Bl -tag -width "Uncompressed" -compact
471 .It Em Total
472 number of wired bytes used for the ZFS ARC
473 .It Em MRU
474 number of ARC bytes holding most recently used data
475 .It Em MFU
476 number of ARC bytes holding most frequently used data
477 .It Em Anon
478 number of ARC bytes holding in flight data
479 .It Em Header
480 number of ARC bytes holding headers
481 .It Em Other
482 miscellaneous ARC bytes
483 .It Em Compressed
484 bytes of memory used by ARC caches
485 .It Em Uncompressed
486 bytes of data stored in ARC caches before compression
487 .It Em Ratio
488 compression ratio of data cached in the ARC
489 .El
490 .Ss Swap Stats
491 .Bl -tag -width "Uncompressed" -compact
492 .It Em Total
493 total available swap usage
494 .It Em Free
495 total free swap usage
496 .It Em Inuse
497 swap usage
498 .It Em \&In
499 bytes paged in from swap devices (last interval)
500 .It Em Out
501 bytes paged out to swap devices (last interval)
502 .El
503 .Sh ENVIRONMENT
504 .Bl -tag -width "Uncompressed"
505 .It Ev TOP
506 Default set of arguments to
507 .Nm .
508 .It Ev LC_CTYPE
509 The locale to use when displaying the
510 .Va argv
511 vector when
512 .Fl a
513 flag is specified.
514 .El
515 .Sh SEE ALSO
516 .Xr kill 1 ,
517 .Xr ps 1 ,
518 .Xr stty 1 ,
519 .Xr getrusage 2 ,
520 .Xr humanize_number 3 ,
521 .Xr mem 4 ,
522 .Xr renice 8
523 .Sh AUTHORS
524 .An William LeFebvre, EECS Department, Northwestern University
525 .Sh BUGS
526 The command name for swapped processes should be tracked down, but this
527 would make the program run slower.
528 .Pp
529 As with
530 .Xr ps 1 ,
531 things can change while
532 .Nm
533 is collecting information for an update.
534 The picture it gives is only a close approximation to reality.