Annotation of src/usr.bin/top/top.1, Revision 1.70
1.70 ! kn 1: .\" $OpenBSD: top.1,v 1.69 2018/07/25 17:24:14 bluhm Exp $
1.2 downsj 2: .\"
3: .\" Copyright (c) 1997, Jason Downs. All rights reserved.
4: .\"
5: .\" Redistribution and use in source and binary forms, with or without
6: .\" modification, are permitted provided that the following conditions
7: .\" are met:
8: .\" 1. Redistributions of source code must retain the above copyright
9: .\" notice, this list of conditions and the following disclaimer.
10: .\" 2. Redistributions in binary form must reproduce the above copyright
11: .\" notice, this list of conditions and the following disclaimer in the
12: .\" documentation and/or other materials provided with the distribution.
13: .\"
14: .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS
15: .\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16: .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17: .\" DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT,
18: .\" INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19: .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20: .\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21: .\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22: .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23: .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24: .\" SUCH DAMAGE.
25: .\"
1.70 ! kn 26: .Dd $Mdocdate: July 25 2018 $
1.2 downsj 27: .Dt TOP 1
1.10 aaron 28: .Os
1.2 downsj 29: .Sh NAME
30: .Nm top
1.5 aaron 31: .Nd display and update information about the top CPU processes
1.2 downsj 32: .Sh SYNOPSIS
1.6 aaron 33: .Nm top
1.45 jmc 34: .Bk -words
1.59 jsing 35: .Op Fl 1bCHIinqSu
1.2 downsj 36: .Op Fl d Ar count
1.45 jmc 37: .Op Fl g Ar string
1.23 jmc 38: .Op Fl o Ar field
1.25 otto 39: .Op Fl p Ar pid
1.2 downsj 40: .Op Fl s Ar time
1.61 jmc 41: .Op Fl U Oo - Oc Ns Ar user
1.2 downsj 42: .Op Ar number
1.45 jmc 43: .Ek
1.2 downsj 44: .Sh DESCRIPTION
45: .Nm
46: displays the top processes on the system and periodically updates this
1.13 aaron 47: information.
48: If standard output is an intelligent terminal (see below) then
1.1 downsj 49: as many processes as will fit on the terminal screen are displayed
1.13 aaron 50: by default.
51: Otherwise, a good number of them are shown (around 20).
52: Raw CPU percentage is used to rank the processes.
53: If
1.2 downsj 54: .Ar number
1.1 downsj 55: is given, then the top
1.2 downsj 56: .Ar number
1.1 downsj 57: processes will be displayed instead of the default.
1.2 downsj 58: .Pp
59: .Nm
1.1 downsj 60: makes a distinction between terminals that support advanced capabilities
1.13 aaron 61: and those that do not.
62: This distinction affects the choice of defaults for certain options.
63: In the remainder of this document, an
1.2 downsj 64: .Em intelligent
65: terminal is one that supports cursor addressing, clear screen, and clear
1.13 aaron 66: to end of line.
67: Conversely, a
1.43 jmc 68: .Em dumb
1.13 aaron 69: terminal is one that does not support such features.
70: If the output of
1.2 downsj 71: .Nm
1.1 downsj 72: is redirected to a file, it acts as if it were being run on a dumb
73: terminal.
1.12 aaron 74: .Pp
75: The options are as follows:
1.15 aaron 76: .Bl -tag -width Ds
1.51 tedu 77: .It Fl 1
1.58 jmc 78: Display combined CPU statistics for all processors on a single line
79: instead of one line per CPU.
1.64 dlg 80: If there are more than 8 CPUs detected in the system this option
81: is automatically enabled.
1.2 downsj 82: .It Fl b
83: Use
84: .Em batch
1.13 aaron 85: mode.
86: In this mode, all input from the terminal is ignored.
87: Interrupt characters (such as
88: .Ql ^C
89: and
90: .Ql ^\e )
91: still have an effect.
1.1 downsj 92: This is the default on a dumb terminal, or when the output is not a terminal.
1.34 otto 93: .It Fl C
1.42 jmc 94: Show command line arguments
95: as well as the process itself.
1.23 jmc 96: .It Fl d Ar count
97: Show only
98: .Ar count
99: displays, then exit.
100: A display is considered to be one update of the screen.
101: This option allows the user to select the number of displays
102: to be shown before
103: .Nm
104: automatically exits.
105: For intelligent terminals, no upper limit is set.
106: The default is 1 for dumb terminals.
1.45 jmc 107: .It Fl g Ar string
108: Display only processes that contain
109: .Ar string
1.35 otto 110: in their command name.
1.67 edd 111: If displaying of arguments is enabled, the arguments are searched too.
1.59 jsing 112: .It Fl H
113: Show process threads in the display.
114: Normally, only the main process is shown.
115: This option makes all threads visible.
1.27 jmc 116: .It Fl I
117: Do not display idle processes.
118: By default,
119: .Nm
120: displays both active and idle processes.
1.2 downsj 121: .It Fl i
122: Use
123: .Em interactive
1.13 aaron 124: mode.
125: In this mode, any input is immediately read for processing.
126: See the section on
1.2 downsj 127: .Sx INTERACTIVE MODE
1.13 aaron 128: for an explanation of which keys perform what functions.
129: After the command
1.2 downsj 130: is processed, the screen will immediately be updated, even if the command was
1.13 aaron 131: not understood.
132: This mode is the default when standard output is an intelligent terminal.
1.2 downsj 133: .It Fl n
1.10 aaron 134: Use
1.2 downsj 135: .Em non-interactive
1.13 aaron 136: mode.
137: This is identical to
1.2 downsj 138: .Em batch
1.1 downsj 139: mode.
1.23 jmc 140: .It Fl o Ar field
1.45 jmc 141: Sort the process display area using the specified
142: .Ar field
143: as the primary key.
1.23 jmc 144: The field name is the name of the column as seen in the output,
145: but in lower case.
146: The
147: .Ox
1.26 jaredy 148: version of
149: .Nm
150: supports
1.23 jmc 151: .Ar cpu ,
152: .Ar size ,
153: .Ar res ,
154: .Ar time ,
1.54 tedu 155: .Ar pri ,
156: .Ar pid ,
1.23 jmc 157: and
1.54 tedu 158: .Ar command .
1.25 otto 159: .It Fl p Ar pid
160: Show only the process
161: .Ar pid .
1.2 downsj 162: .It Fl q
1.1 downsj 163: Renice
1.2 downsj 164: .Nm
1.26 jaredy 165: to \-20 so that it will run faster.
1.13 aaron 166: This can be used when the system is
1.1 downsj 167: being very sluggish to improve the possibility of discovering the problem.
168: This option can only be used by root.
1.27 jmc 169: .It Fl S
170: Show system processes in the display.
171: Normally, system processes such as the pager and the swapper are not shown.
172: This option makes them visible.
1.23 jmc 173: .It Fl s Ar time
174: Set the delay between screen updates to
175: .Ar time
176: seconds.
177: The value may be fractional, to permit delays of less than 1 second.
178: The default delay between updates is 5 seconds.
1.61 jmc 179: .It Fl U Oo - Oc Ns Ar user
1.70 ! kn 180: Show only those processes owned by username or UID
1.45 jmc 181: .Ar user .
1.61 jmc 182: The prefix
183: .Sq -
184: hides processes owned by that user.
1.2 downsj 185: .It Fl u
1.13 aaron 186: Do not take the time to map UID numbers to usernames.
187: Normally,
1.2 downsj 188: .Nm
189: will read as much of the password database as is necessary to map
1.13 aaron 190: all the user ID numbers it encounters into login names.
191: This option
192: disables all that, while possibly decreasing execution time.
193: The UID numbers are displayed instead of the names.
1.2 downsj 194: .El
195: .Pp
1.1 downsj 196: Both
1.2 downsj 197: .Ar count
1.1 downsj 198: and
1.2 downsj 199: .Ar number
200: fields can be specified as
201: .Li infinite ,
1.13 aaron 202: indicating that they can stretch as far as possible.
203: This is accomplished by using any proper prefix of the keywords
1.2 downsj 204: .Li infinity ,
205: .Li maximum ,
1.1 downsj 206: or
1.2 downsj 207: .Li all .
1.1 downsj 208: The default for
1.2 downsj 209: .Ar count
1.1 downsj 210: on an intelligent terminal is, in fact,
1.2 downsj 211: .Li infinity .
212: .Pp
1.1 downsj 213: The environment variable
1.2 downsj 214: .Ev TOP
1.13 aaron 215: is examined for options before the command line is scanned.
216: This enables a user to set his or her own defaults.
217: The number of processes to display
1.1 downsj 218: can also be specified in the environment variable
1.2 downsj 219: .Ev TOP .
220: .Pp
1.1 downsj 221: The options
1.2 downsj 222: .Fl I ,
223: .Fl S ,
1.1 downsj 224: and
1.2 downsj 225: .Fl u
1.13 aaron 226: are actually toggles.
227: A second specification of any of these options
228: will negate the first.
229: Thus a user who has the environment variable
1.2 downsj 230: .Ev TOP
1.10 aaron 231: set to
1.5 aaron 232: .Dq -I
1.10 aaron 233: may use the command
1.5 aaron 234: .Dq top -I
1.2 downsj 235: to see idle processes.
236: .Sh INTERACTIVE MODE
1.1 downsj 237: When
1.2 downsj 238: .Nm
239: is running in
240: .Em interactive mode ,
1.13 aaron 241: it reads commands from the terminal and acts upon them accordingly.
242: In this mode, the terminal is put in
1.2 downsj 243: .Dv CBREAK ,
1.13 aaron 244: so that a character will be processed as soon as it is typed.
245: Almost always, a key will be pressed when
1.2 downsj 246: .Nm
1.1 downsj 247: is between displays; that is, while it is waiting for
1.2 downsj 248: .Ar time
1.13 aaron 249: seconds to elapse.
250: If this is the case, the command will be
1.1 downsj 251: processed and the display will be updated immediately thereafter
1.13 aaron 252: (reflecting any changes that the command may have specified).
253: This happens even if the command was incorrect.
254: If a key is pressed while
1.2 downsj 255: .Nm
1.1 downsj 256: is in the middle of updating the display, it will finish the update and
1.13 aaron 257: then process the command.
258: Some commands require additional information,
259: and the user will be prompted accordingly.
260: While typing this information
1.1 downsj 261: in, the user's erase and kill keys (as set up by the command
1.2 downsj 262: .Xr stty 1 )
1.1 downsj 263: are recognized, and a newline terminates the input.
1.2 downsj 264: .Pp
1.1 downsj 265: These commands are currently recognized (^L refers to control-L):
1.2 downsj 266: .Bl -tag -width XxXXXX
1.65 bentley 267: .It h | \&?
1.27 jmc 268: Display a summary of the commands (help screen).
1.2 downsj 269: .It ^L
1.1 downsj 270: Redraw the screen.
1.55 lum 271: .It <space>
272: Update the screen.
1.2 downsj 273: .It q
1.1 downsj 274: Quit
1.40 jmc 275: .Nm .
1.23 jmc 276: .El
277: .Bl -tag -width XxXXXX
1.38 otto 278: .It +
1.39 jmc 279: Reset any filters put in place by the
280: .Sq g ,
281: .Sq p ,
282: and
283: .Sq u
284: interactive commands,
1.48 jmc 285: or their command line equivalents,
286: or any process highlighting put in place by the
287: .Sq P
288: interactive command.
1.53 jmc 289: .It 1
1.63 dlg 290: Toggle the display of per CPU or combined CPU statistics.
1.29 markus 291: .It C
292: Toggle the display of process command line arguments.
1.44 jmc 293: .It d Ar count
294: Show only
295: .Ar count
296: displays,
297: then exit.
1.23 jmc 298: .It e
299: Display a list of system errors (if any) generated by the last
300: .Li kill
301: or
302: .Li renice
303: command.
1.40 jmc 304: .It g Ar string
305: Display only processes that contain
306: .Ar string
307: in their command name.
1.67 edd 308: If displaying of arguments is enabled, the arguments are searched too.
1.40 jmc 309: .Sq g+
310: shows all processes.
1.59 jsing 311: .It H
312: Toggle the display of process threads.
1.65 bentley 313: .It I | i
1.23 jmc 314: Toggle the display of idle processes.
1.41 jmc 315: .It Xo k
316: .Op - Ns Ar sig
317: .Ar pid
318: .Xc
319: Send signal
320: .No - Ns Ar sig
1.21 jmc 321: .Pf ( Dv TERM
1.41 jmc 322: by default) to process
323: .Ar pid .
1.13 aaron 324: This acts similarly to the command
1.2 downsj 325: .Xr kill 1 .
1.44 jmc 326: .It n\*(Ba# Ar count
327: Show
328: .Ar count
1.40 jmc 329: processes.
330: .It o Ar field
1.45 jmc 331: Sort the process display area using the specified
332: .Ar field
333: as the primary key.
1.23 jmc 334: Values are the same as for the
335: .Fl o
336: flag, as detailed above.
1.46 otto 337: .It P Ar pid
338: Highlight a specific process, selected by
339: .Ar pid .
1.48 jmc 340: .Sq P+
341: removes process highlighting.
1.40 jmc 342: .It p Ar pid
1.45 jmc 343: Show only the process
1.40 jmc 344: .Ar pid .
345: .Sq p+
346: shows all processes.
1.44 jmc 347: .It r Ar count pid
1.2 downsj 348: Change the priority (the
349: .Em nice )
1.44 jmc 350: of a list of processes to
351: .Ar count
1.40 jmc 352: for process
353: .Ar pid .
1.13 aaron 354: This acts similarly to the command
1.2 downsj 355: .Xr renice 8 .
1.27 jmc 356: .It S
357: Toggle the display of system processes.
1.44 jmc 358: .It s Ar time
359: Set the delay between screen updates to
360: .Ar time
1.40 jmc 361: seconds.
1.61 jmc 362: .It u Oo - Oc Ns Ar user
1.70 ! kn 363: Show only those processes owned by username or UID
1.40 jmc 364: .Ar user .
365: .Sq u+
366: shows processes belonging to all users.
1.60 brynet 367: The
1.61 jmc 368: .Sq -
1.60 brynet 369: prefix hides processes belonging to a single
370: .Ar user .
1.2 downsj 371: .El
372: .Sh THE DISPLAY
373: .\" The actual display varies depending on the specific variant of Unix
374: .\" that the machine is running. This description may not exactly match
375: .\" what is seen by top running on this particular machine. Differences
376: .\" are listed at the end of this manual entry.
377: .\" .Pp
1.1 downsj 378: The top few lines of the display show general information
379: about the state of the system, including
1.11 millert 380: .\" the last process ID assigned to a process,
1.2 downsj 381: .\" (on most systems),
1.24 millert 382: the three load average numbers,
1.56 otto 383: the hostname,
1.1 downsj 384: the current time,
385: the number of existing processes,
386: the number of processes in each state
1.26 jaredy 387: (starting, running, idle, stopped, zombie, dead, and on processor),
1.1 downsj 388: and a percentage of time spent in each of the processor states
1.69 bluhm 389: (user, nice, system, spinning, interrupt, and idle).
1.17 aaron 390: It also includes information about physical and virtual memory allocation.
1.24 millert 391: The load average numbers give the number of jobs in the run queue averaged
1.26 jaredy 392: over 1, 5, and 15 minutes.
1.2 downsj 393: .Pp
1.1 downsj 394: The remainder of the screen displays information about individual
1.13 aaron 395: processes.
396: This display is similar in spirit to
1.2 downsj 397: .Xr ps 1
1.13 aaron 398: but it is not exactly the same.
1.26 jaredy 399: The following fields are displayed:
400: .Bl -tag -width USERNAME -offset indent
401: .It PID
402: The process ID.
403: .It USERNAME
404: The name of the process's owner.
1.66 mpi 405: .It TID
406: The thread ID, used instead of USERNAME if
407: .Fl H
408: is specified.
1.26 jaredy 409: .It UID
410: Used instead of USERNAME if
1.2 downsj 411: .Fl u
1.26 jaredy 412: is specified.
413: .It PRI
414: The current priority of the process.
415: .It NICE
416: The nice amount (in the range \-20 to 20).
417: .It SIZE
418: The total size of the process (the text, data, and stack segments).
419: .It RES
420: The current amount of resident memory.
421: .It STATE
422: The current state (one of
423: .Li start ,
424: .Li run ,
1.2 downsj 425: .Li sleep ,
1.26 jaredy 426: .Li stop ,
427: .Li idle ,
1.2 downsj 428: .Li zomb ,
1.26 jaredy 429: .Li dead ,
1.2 downsj 430: or
1.26 jaredy 431: .Li onproc ) .
1.57 sobrado 432: On multiprocessor systems, this is followed by a slash and the CPU
1.26 jaredy 433: number on which the process is bound.
434: .It WAIT
435: A description of the wait channel the process is sleeping on if it's
436: asleep.
437: .It TIME
438: The number of system and user CPU seconds that the process has used.
439: .It CPU
440: The raw percentage of CPU usage and the default field on which the
441: display is sorted.
442: .It COMMAND
443: The name of the command that the process is currently running.
444: (If the process is swapped out, this column is enclosed by angle
445: brackets.)
446: .El
1.2 downsj 447: .Sh ENVIRONMENT
1.26 jaredy 448: .Bl -tag -width Ev
1.2 downsj 449: .It Ev TOP
450: User-configurable defaults for options.
451: .El
452: .Sh FILES
1.50 jmc 453: .Bl -tag -width "/etc/passwdXXX" -compact
1.2 downsj 454: .It Pa /dev/kmem
455: kernel memory
456: .It Pa /dev/mem
457: physical memory
1.26 jaredy 458: .It Pa /etc/passwd
1.49 jmc 459: used to map user ID to user
1.2 downsj 460: .It Pa /bsd
461: kernel image
1.14 aaron 462: .El
1.13 aaron 463: .Sh SEE ALSO
1.30 jmc 464: .Xr fstat 1 ,
1.13 aaron 465: .Xr kill 1 ,
1.30 jmc 466: .Xr netstat 1 ,
1.13 aaron 467: .Xr ps 1 ,
468: .Xr stty 1 ,
469: .Xr systat 1 ,
470: .Xr mem 4 ,
1.30 jmc 471: .Xr iostat 8 ,
472: .Xr pstat 8 ,
473: .Xr renice 8 ,
1.31 jmc 474: .Xr vmstat 8
1.16 aaron 475: .Sh AUTHORS
1.62 schwarze 476: .An William LeFebvre ,
477: EECS Department, Northwestern University
1.68 tedu 478: .Sh CAVEATS
1.1 downsj 479: As with
1.2 downsj 480: .Xr ps 1 ,
481: .Nm
1.68 tedu 482: only provides snapshots of a constantly changing system.