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