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