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