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