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