Merge branch 'vendor/LIBARCHIVE'
[dragonfly.git] / usr.bin / top / top.1
1 .nr N 30
2 .nr D 5
3 .nr L 1
4 .nr K 1
5 .TH TOP 1 "December 20, 2009"
6 .SH NAME
7 top \- display and update information about the top cpu processes
8 .SH SYNOPSIS
9 .B top
10 [
11 .B \-CIMSTabcinqtuv
12 ] [
13 .BI \-d count
14 ] [
15 .BI \-m mode
16 ] [
17 .BI \-o field
18 ] [
19 .BI \-s time
20 ] [
21 .BI \-U username
22 ] [
23 .I number
24 ]
25 .SH DESCRIPTION
26 .\" This defines appropriate quote strings for nroff and troff
27 .ds lq \&"
28 .ds rq \&"
29 .if t .ds lq ``
30 .if t .ds rq ''
31 .\" Just in case these number registers aren't set yet...
32 .if \nN==0 .nr N 10
33 .if \nD==0 .nr D 5
34 .I Top
35 displays the top
36 .if !\nN==-1 \nN
37 processes on the system and periodically updates this information.
38 .if \nN==-1 \
39 \{\
40 If standard output is an intelligent terminal (see below) then
41 as many processes as will fit on the terminal screen are displayed
42 by default.  Otherwise, a good number of them are shown (around 20).
43 .\}
44 Raw cpu percentage is used to rank the processes.  If
45 .I number
46 is given, then the top
47 .I number
48 processes will be displayed instead of the default.
49 .PP
50 .I Top
51 makes a distinction between terminals that support advanced capabilities
52 and those that do not.  This
53 distinction affects the choice of defaults for certain options.  In the
54 remainder of this document, an \*(lqintelligent\*(rq terminal is one that
55 supports cursor addressing, clear screen, and clear to end of line.
56 Conversely, a \*(lqdumb\*(rq terminal is one that does not support such
57 features.  If the output of
58 .I top
59 is redirected to a file, it acts as if it were being run on a dumb
60 terminal.
61 .SH OPTIONS
62 .if \nL==0 Long options are not available on this system.
63 .TP
64 .B "\-C, \-\-color"
65 Turn off the use of color in the display.
66 .TP
67 .B "\-I, \-\-idle-procs"
68 Do not display idle processes.
69 By default, top displays both active and idle processes.
70 .TP
71 .B "\-M"
72 Enable multi-CPU display.
73 .TP
74 .B "\-S, \-\-system-procs"
75 Show system processes in the display.  Normally, system processes such as
76 the pager and the swapper are not shown.  This option makes them visible.
77 .TP
78 .B "\-T, \-\-tag-names"
79 List all available color tags and the current set of tests used for
80 color highlighting, then exit.
81 .TP
82 .B "\-a, \-\-all"
83 Show all processes for as long as possible.  This is shorthand for
84 \*(lq-d all all\*(rq.  This option is especially handy in batch mode.
85 .TP
86 .B "\-b, \-n, \-\-batch"
87 Use \*(lqbatch\*(rq mode.  In this mode, all input from the terminal is
88 ignored.  Interrupt characters (such as ^C and ^\e) still have an effect.
89 This is the default on a dumb terminal, or when the output is not a terminal.
90 .TP
91 .B "\-c, \-\-full-commands"
92 Show the full command line for each process. Default is to show just the
93 command name.  This option is not supported on all platforms.
94 .TP
95 .B "\-i, \-\-interactive"
96 Use \*(lqinteractive\*(rq mode.  In this mode, any input is immediately
97 read for processing.  See the section on \*(lqInteractive Mode\*(rq
98 for an explanation of
99 which keys perform what functions.  After the command is processed, the
100 screen will immediately be updated, even if the command was not
101 understood.  This mode is the default when standard output is an
102 intelligent terminal.
103 .TP
104 .B "\-q, \-\-quick"
105 Renice
106 .I top
107 to -20 so that it will run faster.  This can be used when the system is
108 being very sluggish to improve the possibility of discovering the problem.
109 This option can only be used by root.
110 .TP
111 .B "\-t, \-\-threads"
112 Show individual threads on separate lines.  By default, on systems
113 which support threading, each process is shown with a count of the number
114 of threads. This option shows each thread on a separate line.  This option
115 is not supported on all platforms.
116 .TP
117 .B "\-u, \-\-uids"
118 Do not take the time to map uid numbers to usernames.  Normally,
119 .I top
120 will read as much of the file \*(lq/etc/passwd\*(rq as is necessary to map
121 all the user id numbers it encounters into login names.  This option
122 disables all that, while possibly decreasing execution time.  The uid
123 numbers are displayed instead of the names.
124 .TP
125 .B "\-v, \-\-version"
126 Write version number information to stderr then exit immediately.
127 No other processing takes place when this option is used.  To see current
128 revision information while top is running, use the help command \*(lq?\*(rq.
129 .TP
130 .B "\-d \fIcount\fP, \-\-displays \fIcount\fP"
131 Show only
132 .I count
133 displays, then exit.  A display is considered to be one update of the
134 screen.  This option allows the user to select the number of displays he
135 wants to see before
136 .I top
137 automatically exits.  Any proper prefix of the words \*(lqinfinity\*(rq,
138 \*(lqmaximum\*(rq,
139 or
140 \*(lqall\*(rq can be used to indicate an infinite number of displays.
141 The default for intelligent terminals is infinity.
142 The default for dumb terminals is 1.
143 .TP
144 .B "\-m \fImode\fP, \-\-mode=\fImode\fP"
145 Start the display in an alternate mode.  Some platforms support multiple
146 process displays to show additional process information.  The value
147 \fImode\fP is a number indicating which mode to display.  The default is
148 0.  On platforms that do not have multiple display modes this option has
149 no effect.
150 .TP
151 .B "\-o \fIfield\fP, \-\-sort-order=\fIfield\fP"
152 Sort the process display area on the specified field.  The field name is
153 the name of the column as seen in the output, but in lower case.  Likely
154 values are \*(lqcpu\*(rq, \*(lqsize\*(rq, \*(lqres\*(rq, and \*(lqtime\*(rq,
155 but may vary on different operating systems.  Note that
156 not all operating systems support this option.
157 .TP
158 .B "\-s \fItime\fP, \-\-delay=\fItime\fP"
159 Set the delay between screen updates to
160 .I time
161 seconds.  The default delay between updates is \nD seconds.
162 .TP
163 .B "\-U \fIusername\fP, \-\-user=\fIusername\fP"
164 Show only those processes owned by
165 .IR username .
166 This option currently only accepts usernames and will not understand
167 uid numbers.
168 .PP
169 Both
170 .I count
171 and
172 .I number
173 fields can be specified as \*(lqinfinite\*(rq, indicating that they can
174 stretch as far as possible.  This is accomplished by using any proper
175 prefix of the keywords
176 \*(lqinfinity\*(rq,
177 \*(lqmaximum\*(rq,
178 or
179 \*(lqall\*(rq.
180 The default for
181 .I count
182 on an intelligent terminal is, in fact,
183 \fBinfinity\fP.
184 .PP
185 The environment variable
186 .B TOP
187 is examined for options before the command line is scanned.  This enables
188 a user to set his or her own defaults.  The number of processes to display
189 can also be specified in the environment variable
190 .BR TOP .
191 The options
192 .BR \-C ,
193 .BR \-I ,
194 .BR \-S ,
195 and
196 .B \-u
197 are actually toggles.  A second specification of any of these options
198 will negate the first.  Thus a user who has the environment variable
199 .B TOP
200 set to \*(lq\-I\*(rq may use the command \*(lqtop \-I\*(rq to see idle processes.
201 .SH "INTERACTIVE MODE"
202 When
203 .I top
204 is running in \*(lqinteractive mode\*(rq, it reads commands from the
205 terminal and acts upon them accordingly.  In this mode, the terminal is
206 put in \*(lqCBREAK\*(rq, so that a character will be
207 processed as soon as it is typed.  Almost always, a key will be
208 pressed when
209 .I top
210 is between displays; that is, while it is waiting for
211 .I time
212 seconds to elapse.  If this is the case, the command will be
213 processed and the display will be updated immediately thereafter
214 (reflecting any changes that the command may have specified).  This
215 happens even if the command was incorrect.  If a key is pressed while 
216 .I top
217 is in the middle of updating the display, it will finish the update and
218 then process the command.  Some commands require additional information,
219 and the user will be prompted accordingly.  While typing this information
220 in, the user's erase and kill keys (as set up by the command
221 .IR stty )
222 are recognized, and a newline terminates the input.  Note that a control-L
223 (^L) always redraws the current screen and a space forces an immediate
224 update to the screen using new data.
225 .PP
226 These commands are currently recognized:
227 .TP
228 .I "\fBh\fP\ or\ \fB?\fP"
229 Display a summary of the commands (help screen).  Version information
230 is included in this display.
231 .TP
232 .B C
233 Toggle the use of color in the display.
234 .TP
235 .B c
236 Display only processes whose commands match the specified string.  An empty
237 string will display all processes.  This command is not supported on all 
238 platforms.
239 .TP
240 .B d
241 Change the number of displays to show (prompt for new number).
242 Remember that the next display counts as one, so typing
243 .B d1
244 will make
245 .I top
246 show one final display and then immediately exit.
247 .TP
248 .B f
249 Toggle the display of the full command line.
250 .TP
251 .B H
252 Toggle the display of threads on separate lines.  By default, on systems
253 which support threading, each process is shown with a count of the number
254 of threads. This command shows each thread on a separate line.  This command
255 is not supported on all platforms.
256 .TP
257 .B i
258 (or
259 .BR I )
260 Toggle the display of idle processes.
261 .if \nK==1 \{\
262 .TP
263 .B k
264 Send a signal (\*(lqkill\*(rq by default) to a list of processes.  This
265 acts similarly to the command
266 .IR kill (1)).
267 .\}
268 .TP
269 .B M
270 Sort display by memory usage.  Shorthand for \*(lqo size\*(rq.
271 .TP
272 .B m
273 Change to a different process display mode.  Some systems provide multiple
274 display modes for the process display which shows different information.
275 This command toggles between the available modes.  This command is not 
276 supported on all platforms.
277 .TP
278 .B N
279 Sort by process id.  Shorthand for \*(lqo pid\*(rq.
280 .TP
281 .B n or #
282 Change the number of processes to display (prompt for new number).
283 .TP
284 .B o
285 Change the order in which the display is sorted.  This command is not
286 available on all systems.  The sort key names vary fron system to system
287 but usually include:  \*(lqcpu\*(rq, \*(lqres\*(rq, \*(lqsize\*(rq,
288 \*(lqtime\*(rq.  The default is cpu.
289 .TP
290 .B P
291 Sort by CPU usage.  Shorthand for \*(lqo cpu\*(rq.
292 .TP
293 .B q
294 Quit
295 .IR top.
296 .if \nK==1 \{\
297 .TP
298 .B r
299 Change the priority (the \*(lqnice\*(rq) of a list of processes.
300 This acts similarly to the command
301 .IR renice (8)).
302 .\}
303 .TP
304 .B s
305 Change the number of seconds to delay between displays
306 (prompt for new number).
307 .TP
308 .B T
309 Sort by CPU time.  Shorthand for \*(lqo time\*(rq.
310 .TP
311 .B U
312 Toggle between displaying usernames and uids.
313 .TP
314 .B u
315 Display only processes owned by a specific username (prompt for username).
316 If the username specified is simply \*(lq+\*(rq, then processes belonging
317 to all users will be displayed.
318 .SH "THE DISPLAY"
319 The actual display varies depending on the specific variant of Unix
320 that the machine is running.  This description may not exactly match
321 what is seen by top running on this particular machine.  Differences
322 are listed at the end of this manual entry.
323 .PP
324 The top lines of the display show general information
325 about the state of the system.  The first line shows
326 (on some systems) the last process id assigned to a process,
327 the three load averages,
328 the system uptime, and the current time.
329 The second line displays the total number of processes followed
330 by a breakdown of processes per state.  Examples of states common
331 to Unix systems are sleeping, running, starting, stopped, and zombie.
332 The next line displays a percentage of time spent in each of the
333 processor states (typically user, nice, system, idle, and iowait).
334 These percentages show the processor activity during the time since
335 the last update.  For multi-processor systems, this information is 
336 a summation of time across all processors.  The next line shows
337 kernel-related activity (not available on all systems).  The numbers
338 shown on this line are per-second rates sampled since the last update.
339 The exact
340 information displayed varies between systems, but some examples are:
341 context switches, interrupts, traps, forks, and page faults.
342 .PP
343 The last
344 two lines show a summary of memory and swap activity.  The fields are
345 as follows:
346 .TP
347 .B Active:
348 number of pages active
349 .TP
350 .B Inact:
351 number of pages inactive
352 .TP
353 .B Wired:
354 number of pages wired down, including cached file data pages
355 .TP
356 .B Cache:
357 number of pages used for VM-level disk caching
358 .TP
359 .B Buf:
360 number of pages used for BIO-level disk caching
361 .TP
362 .B Free:
363 number of pages free
364 .TP
365 .B Total:
366 total available swap usage
367 .TP
368 .B Free:
369 total free swap usage
370 .TP
371 .B Inuse:
372 swap usage
373 .TP
374 .B In:
375 pages paged in from swap devices (last interval)
376 .TP
377 .B Out:
378 pages paged out to swap devices (last interval)
379 .TP
380 .B K:
381 Kilobyte
382 .TP
383 .B M:
384 Megabyte
385 .TP
386 .B %:
387 1/100
388 .PP
389 The remainder of the screen displays information about individual
390 processes.  This display is similar in spirit to
391 .IR ps (1)
392 but it is not exactly the same.  The columns displayed by top will
393 differ slightly between operating systems.  Generally, the following
394 fields are displayed:
395 .TP
396 .B PID
397 The process id.
398 .TP
399 .B USERNAME
400 Username of the process's owner (if
401 .B \-u
402 is specified, a UID column will be substituted for USERNAME).
403 .TP
404 .B THR
405 The number of threads in the processes (this column may also
406 be labeled NLWP).
407 .TP
408 .B PRI
409 Current priority of the process.  This field is no longer displayed.
410 .TP
411 .B NICE
412 Nice amount in the range \-20 to 20, as established by the use of
413 the command
414 .IR nice .
415 .TP
416 .B SIZE
417 Total size of the process (text, data, and stack) given in kilobytes.
418 .TP
419 .B PRES
420 Proportional resident memory: current amount of process memory that resides
421 in physical memory, given in kilobytes.  Shared memory is divided amoungst
422 the processes doing the sharing.  This field replaces RES.
423 .TP
424 .B STATE
425 Current state (typically one of \*(lqsleep\*(rq,
426 \*(lqrun\*(rq, \*(lqidl\*(rq, \*(lqzomb\*(rq, or \*(lqstop\*(rq).
427 .TP
428 .B C
429 Number of CPU the process is currently running on (only on multi-CPU machines).
430 .TP
431 .B TIME
432 Number of system and user cpu seconds that the process has used.
433 .TP
434 .B CTIME
435 The cumulated CPU time of the process and its exited children.  This value
436 is similar to what
437 .IR ps (1)
438 displays as CPU time when run with the
439 .BR \-S
440 option.
441 .TP
442 .B CPU
443 Percentage of available cpu time used by this process.
444 .TP
445 .B COMMAND
446 Name of the command that the process is currently running.
447 .SH COLOR
448 Top supports the use of ANSI color in its output. By default, color is
449 available but not used.  The environment variable
450 .B TOPCOLORS
451 specifies colors to use and conditions for which they should be used.
452 At the present time, only numbers in the summay display area can be 
453 colored. In a future version it will be possible to highlight numbers
454 in the process display area as well.  The environment variable is the
455 only way to specify color: there is no equivalent command line option.
456 Note that the environment variable
457 .B TOPCOLOURS
458 is also understood. The British spelling takes precedence.  The use of
459 color only works on terminals that understand and process ANSI color
460 escape sequences.
461 .PP
462 The environment variable is a sequence of color specifications, separated
463 by colons. Each specification takes the form tag=min,max#code where
464 .I tag
465 is the name of the value to check,
466 .I min
467 and
468 .I max
469 specify a range for the value, and
470 .I code
471 is an ANSI color code.  Multiple color codes can be listed and separated
472 with semi-colons.  A missing
473 .I min
474 implies the lowest possible value (usually 0)
475 and a missing
476 .I max
477 implies infinity. The comma must always be present. When specifying numbers
478 for load averages, they should be multiplied by 100.
479 For example, the specification
480 .B 1min=500,1000#31
481 indicates that a 1 minute load average between
482 5 and 10 should be displayed in red. Color attributes can be combined.
483 For example, the specification
484 .B 5min=1000,#37;41
485 indicates that a 5 minute load average higher than 10 should be displayed
486 with white characters on a red background. A special tag named
487 .I header
488 is used to control the color of the header for process display.  It should
489 be specified with no lower and upper limits, specifically
490 .B header=,#
491 followed by the ANSI color code.
492 .PP
493 You can see a list of color codes recognized by this installation of top
494 with the
495 .B \-T
496 option.  This will also show the current set of tests used for
497 color highligting, as specified in the environment.
498 .SH AUTHOR
499 William LeFebvre
500 .SH ENVIRONMENT
501 .DT
502 TOP             user-configurable defaults for options.
503 TOPCOLORS       color specification
504 .SH BUGS
505 As with
506 .IR ps (1),
507 things can change while
508 .I top
509 is collecting information for an update.  The picture it gives is only a
510 close approximation to reality.
511 .SH "SEE ALSO"
512 kill(1),
513 ps(1),
514 stty(1),
515 mem(4),
516 renice(8)
517 .SH COPYRIGHT
518 Copyright (C) 1984-2007 William LeFebvre. For additional licensing
519 information, see http://www.unixtop.org/license/