1TOP(1) Linux User's Manual TOP(1)
2
3
4
6 top - display Linux tasks
7
8
9
11 ⟨⟩
12 -hv | -abcHimMsS -d delay -n iterations -p pid [, pid ...]
13
14 The traditional switches '-' and whitespace are optional.
15
16
17
19 The .ie 0 . br
20 program provides a dynamic real-time view of a running system.
21 It can display system summary information as well as a list of
22 tasks currently being managed by the Linux kernel. The types of
23 system summary information shown and the types, order and size of
24 information displayed for tasks are all user configurable and that
25 configuration can be made persistent across restarts.
26
27 The program provides a limited interactive interface for process
28 manipulation as well as a much more extensive interface for per‐
29 sonal configuration -- encompassing every aspect of its opera‐
30 tion. And while .ie 0 . br
31 is referred to throughout this document, you are free to name the
32 program anything you wish. That new name, possibly an alias, will
33 then be reflected on top's display and used when reading and writ‐
34 ing a configuration file.
35
36
37
39 Documentation
40 The remaining Table of Contents
41 1. COMMAND-LINE Options
42 2. FIELDS / Columns
43 a. DESCRIPTIONS of Fields
44 b. SELECTING and ORDERING Columns
45 3. INTERACTIVE Commands
46 a. GLOBAL Commands
47 b. SUMMARY Area Commands
48 c. TASK Area Commands
49 d. COLOR Mapping
50 4. ALTERNATE-DISPLAY Mode
51 a. WINDOWS Overview
52 b. COMMANDS for Windows
53 5. FILES
54 a. SYSTEM Configuration File
55 b. PERSONAL Configuration File
56 6. STUPID TRICKS Sampler
57 a. Kernel Magic
58 b. Bouncing Windows
59 c. The Big Bird Window
60 7. BUGS, 8. HISTORY Former top, 9. AUTHOR, 10. SEE ALSO
61
62
63 Operation
64 When operating top, the two most important keys are help ('h' or
65 '?') and quit ('q') key. Alternatively, you could simply use the
66 traditional interrupt key ('^C') when you're done.
67
68 When you start top for the first time, you'll be presented with
69 the traditional screen elements: 1) Summary Area; 2) Mes‐
70 sage/Prompt Line; 3) Columns Header; 4) Task Area. There will,
71 however, be some differences when compared to the former top.
72
73
74 Highlighting
75 Summary_Area: There is no highlighting for load/uptime and only
76 values are highlighted for other elements.
77
78 Task_Area: Tasks running (or ready to run) will be highlighted,
79 and bold is only one way of emphasizing such processes.
80
81
82 Content/Labels
83 Summary_Area: The program name is shown, perhaps a symlink or
84 alias. The Cpu(s) state label hints at other possibilities.
85 The memory stats use a lower case 'k'.
86
87 Columns_Header: Will show a new field and some changed labels.
88 More new fields will be found as you customize your top.
89
90
91 Note: the width of top's display will be limited to 512 positions.
92 Displaying all fields requires a minimum of 160 characters. The
93 remaining width could be used for the 'Command' column.
94
95
96 Startup Defaults
97 The following startup defaults assume no configuration file, thus
98 no user customizations. Even so, items shown with an asterisk
99 ('*') could be overridden through the command-line.
100
101 Global_defaults
102 'A' - Alt display Off (full-screen)
103 * 'd' - Delay time 3.0 seconds
104 'I' - Irix mode On (no, 'solaris' smp)
105 * 'p' - PID monitoring Off
106 * 's' - Secure mode Off (unsecured)
107 'B' - Bold disable Off
108 Summary_Area_defaults
109 'l' - Load Avg/Uptime On (thus program name)
110 't' - Task/Cpu states On (1+1 lines, see '1')
111 'm' - Mem/Swap usage On (2 lines worth)
112 '1' - Single Cpu On (thus 1 line if smp)
113 Task_Area_defaults
114 'b' - Bold hilite On (not 'reverse')
115 * 'c' - Command line Off (name, not cmdline)
116 * 'H' - Threads Off (show all threads)
117 * 'i' - Idle tasks On (show all tasks)
118 'R' - Reverse sort On (pids high-to-low)
119 * 'S' - Cumulative time Off (no, dead children)
120 'x' - Column hilite Off (no, sort field)
121 'y' - Row hilite On (yes, running tasks)
122 'z' - color/mono Off (no, colors)
123
124
125
127 The command-line syntax for top consists of:
128
129 -hv | -abcHimMsS -d delay -n iterations -p pid [,pid...]
130
131 The typically mandatory switches ('-') and even whitespace are
132 completely optional.
133
134
135 -a : Sort by memory usage
136 This switch makes top to sort the processes by allocated mem‐
137 ory
138
139
140 -b : Batch mode operation
141 Starts top in 'Batch mode', which could be useful for sending
142 output from top to other programs or to a file. In this
143 mode, top will not accept input and runs until the iterations
144 limit you've set with the '-n' command-line option or until
145 killed.
146
147
148 -c : Command line/Program name toggle
149 Starts top with the last remembered 'c' state reversed.
150 Thus, if top was displaying command lines, now that field
151 will show program names, and visa versa. See the 'c' inter‐
152 active command for additional information.
153
154
155 -d : Delay time interval as: -d ss.tt (seconds.tenths)
156 Specifies the delay between screen updates, and overrides the
157 corresponding value in one's personal configuration file or
158 the startup default. Later this can be changed with the 'd'
159 or 's' interactive commands.
160
161 Fractional seconds are honored, but a negative number is not
162 allowed. In all cases, however, such changes are prohibited
163 if top is running in 'Secure mode', except for root (unless
164 the 's' command-line option was used). For additional infor‐
165 mation on 'Secure mode' see topic 5a. SYSTEM Configuration
166 File.
167
168
169 -h : Help
170 Show library version and the usage prompt, then quit.
171
172
173 -H : Threads toggle
174 Starts top with the last remembered 'H' state reversed. When
175 this toggle is On, all individual threads will be displayed.
176 Otherwise, top displays a summation of all threads in a
177 process.
178
179
180 -i : Idle Processes toggle
181 Starts top with the last remembered 'i' state reversed. When
182 this toggle is Off, tasks that are idled or zombied will not
183 be displayed.
184
185
186 -m : VIRT/USED toggle
187 Reports USED (sum of process rss and swap total count)
188 instead of VIRT
189
190
191 -M : Detect memory units
192 Show memory units (k/M/G) and display floating point values
193 in the memory summary.
194
195
196 -n : Number of iterations limit as: -n number
197 Specifies the maximum number of iterations, or frames, top
198 should produce before ending.
199
200
201 -p : Monitor PIDs as: -pN1 -pN2 ... or -pN1, N2 [,...]
202 Monitor only processes with specified process IDs. This
203 option can be given up to 20 times, or you can provide a
204 comma delimited list with up to 20 pids. Co-mingling both
205 approaches is permitted.
206
207 This is a command-line option only. And should you wish to
208 return to normal operation, it is not necessary to quit and
209 and restart top -- just issue the '=' interactive command.
210
211
212 -s : Secure mode operation
213 Starts top with secure mode forced, even for root. This mode
214 is far better controlled through the system configuration
215 file (see topic 5. FILES).
216
217
218 -S : Cumulative time mode toggle
219 Starts top with the last remembered 'S' state reversed. When
220 'Cumulative mode' is On, each process is listed with the cpu
221 time that it and its dead children have used. See the 'S'
222 interactive command for additional information regarding this
223 mode.
224
225
226 -u : Monitor by user as: -u somebody
227 Monitor only processes with an effective UID or user name
228 matching that given.
229
230
231 -U : Monitor by user as: -U somebody
232 Monitor only processes with a UID or user name matching that
233 given. This matches real, effective, saved, and filesystem
234 UIDs.
235
236
237 -v : Version
238 Show library version and the usage prompt, then quit.
239
240
242 2a. DESCRIPTIONS of Fields
243 Listed below are top's available fields. They are always associ‐
244 ated with the letter shown, regardless of the position you may
245 have established for them with the 'o' (Order fields) interactive
246 command.
247
248 Any field is selectable as the sort field, and you control whether
249 they are sorted high-to-low or low-to-high. For additional infor‐
250 mation on sort provisions see topic 3c. TASK Area Commands.
251
252
253 a: PID -- Process Id
254 The task's unique process ID, which periodically wraps, though
255 never restarting at zero.
256
257
258 b: PPID -- Parent Process Pid
259 The process ID of a task's parent.
260
261
262 c: RUSER -- Real User Name
263 The real user name of the task's owner.
264
265
266 d: UID -- User Id
267 The effective user ID of the task's owner.
268
269
270 e: USER -- User Name
271 The effective user name of the task's owner.
272
273
274 f: GROUP -- Group Name
275 The effective group name of the task's owner.
276
277
278 g: TTY -- Controlling Tty
279 The name of the controlling terminal. This is usually the
280 device (serial port, pty, etc.) from which the process was
281 started, and which it uses for input or output. However, a
282 task need not be associated with a terminal, in which case
283 you'll see '?' displayed.
284
285
286 h: PR -- Priority
287 The priority of the task.
288
289
290 i: NI -- Nice value
291 The nice value of the task. A negative nice value means higher
292 priority, whereas a positive nice value means lower priority.
293 Zero in this field simply means priority will not be adjusted
294 in determining a task's dispatchability.
295
296
297 j: P -- Last used CPU (SMP)
298 A number representing the last used processor. In a true SMP
299 environment this will likely change frequently since the kernel
300 intentionally uses weak affinity. Also, the very act of run‐
301 ning top may break this weak affinity and cause more processes
302 to change CPUs more often (because of the extra demand for cpu
303 time).
304
305
306 k: %CPU -- CPU usage
307 The task's share of the elapsed CPU time since the last screen
308 update, expressed as a percentage of total CPU time. In a true
309 SMP environment, if 'Irix mode' is Off, top will operate in
310 'Solaris mode' where a task's cpu usage will be divided by the
311 total number of CPUs. You toggle 'Irix/Solaris' modes with the
312 'I' interactive command.
313
314
315 l: TIME -- CPU Time
316 Total CPU time the task has used since it started. When 'Cumu‐
317 lative mode' is On, each process is listed with the cpu time
318 that it and its dead children has used. You toggle 'Cumulative
319 mode' with 'S', which is a command-line option and an interac‐
320 tive command. See the 'S' interactive command for additional
321 information regarding this mode.
322
323
324 m: TIME+ -- CPU Time, hundredths
325 The same as 'TIME', but reflecting more granularity through
326 hundredths of a second.
327
328
329 n: %MEM -- Memory usage (RES)
330 A task's currently used share of available physical memory.
331
332
333 o: VIRT -- Virtual Image (kb)
334 The total amount of virtual memory used by the task. It
335 includes all code, data and shared libraries plus pages that
336 have been swapped out. (Note: you can define the STATSIZE=1
337 environment variable and the VIRT will be calculated from the
338 /proc/#/state VmSize field.)
339
340
341 p: SWAP -- Swapped size (kb)
342 Per-process swap values are now taken from /proc/#/status
343 VmSwap field.
344
345
346 q: RES -- Resident size (kb)
347 The non-swapped physical memory a task is using.
348
349
350 r: CODE -- Code size (kb)
351 The amount of physical memory devoted to executable code, also
352 known as the 'text resident set' size or TRS.
353
354
355 s: DATA -- Data+Stack size (kb)
356 The amount of physical memory devoted to other than executable
357 code, also known as the 'data resident set' size or DRS.
358
359
360 t: SHR -- Shared Mem size (kb)
361 The amount of shared memory used by a task. It simply reflects
362 memory that could be potentially shared with other processes.
363
364
365 u: nFLT -- Page Fault count
366 The number of major page faults that have occurred for a task.
367 A page fault occurs when a process attempts to read from or
368 write to a virtual page that is not currently present in its
369 address space. A major page fault is when disk access is
370 involved in making that page available.
371
372
373 v: nDRT -- Dirty Pages count
374 The number of pages that have been modified since they were
375 last written to disk. Dirty pages must be written to disk
376 before the corresponding physical memory location can be used
377 for some other virtual page.
378
379
380 w: S -- Process Status
381 The status of the task which can be one of:
382 'D' = uninterruptible sleep
383 'R' = running
384 'S' = sleeping
385 'T' = traced or stopped
386 'Z' = zombie
387
388 Tasks shown as running should be more properly thought of as
389 'ready to run' -- their task_struct is simply represented on
390 the Linux run-queue. Even without a true SMP machine, you may
391 see numerous tasks in this state depending on top's delay
392 interval and nice value.
393
394
395 x: Command -- Command line or Program name
396 Display the command line used to start a task or the name of
397 the associated program. You toggle between command line and
398 name with 'c', which is both a command-line option and an
399 interactive command.
400
401 When you've chosen to display command lines, processes without
402 a command line (like kernel threads) will be shown with only
403 the program name in parentheses, as in this example:
404 ( mdrecoveryd )
405
406 Either form of display is subject to potential truncation if
407 it's too long to fit in this field's current width. That width
408 depends upon other fields selected, their order and the current
409 screen width.
410
411 Note: The 'Command' field/column is unique, in that it is not
412 fixed-width. When displayed, this column will be allocated all
413 remaining screen width (up to the maximum 512 characters) to
414 provide for the potential growth of program names into command
415 lines.
416
417
418 y: WCHAN -- Sleeping in Function
419 Depending on the availability of the kernel link map ('Sys‐
420 tem.map'), this field will show the name or the address of the
421 kernel function in which the task is currently sleeping. Run‐
422 ning tasks will display a dash ('-') in this column.
423
424 Note: By displaying this field, top's own working set will be
425 increased by over 700Kb. Your only means of reducing that
426 overhead will be to stop and restart top.
427
428
429 z: Flags -- Task Flags
430 This column represents the task's current scheduling flags
431 which are expressed in hexadecimal notation and with zeros sup‐
432 pressed. These flags are officially documented in
433 <linux/sched.h>. Less formal documentation can also be found
434 on the 'Fields select' and 'Order fields' screens.
435
436
437 2b. SELECTING and ORDERING Columns
438 After pressing the interactive commands 'f' (Fields select) or ´o'
439 (Order fields) you will be shown a screen containing the current
440 fields string followed by names and descriptions for all fields.
441
442 Here is a sample fields string from one of top's four win‐
443 dows/field groups and an explanation of the conventions used:
444
445 - Sample fields string:
446 ANOPQRSTUVXbcdefgjlmyzWHIK
447
448 - The order of displayed fields corresponds to the order of the
449 letters in that string.
450
451 - If the letter is upper case the corresponding field itself will
452 then be shown as part of the task display (screen width permit‐
453 ting). This will also be indicated by a leading asterisk
454 ('*'), as in this excerpt:
455 ...
456 * K: %CPU = CPU usage
457 l: TIME = CPU Time
458 m: TIME+ = CPU Time, hundredths
459 * N: %MEM = Memory usage (RES)
460 * O: VIRT = Virtual Image (kb)
461 ...
462
463
464 Fields select screen -- the 'f' interactive command
465 You toggle the display of a field by simply pressing the corre‐
466 sponding letter.
467
468
469 Order fields screen -- the 'o' interactive command
470 You move a field to the left by pressing the corresponding
471 upper case letter and to the right with the lower case letter.
472
473
474 2c. SUMMARY Area Fields
475 The summary area fields describing CPU statistics are abbreviated.
476 They provide information about times spent in:
477 us = user mode
478 sy = system mode
479 ni = low priority user mode (nice)
480 id = idle task
481 wa = I/O waiting
482 hi = servicing IRQs
483 si = servicing soft IRQs
484 st = steal (time given to other DomU instances)
485
486
487
489 Listed below is a brief index of commands within categories. Some
490 commands appear more than once -- their meaning or scope may
491 vary depending on the context in which they are issued.
492
493 3a. GLOBAL_Commands
494 <Ret/Sp> ?, =, A, B, d, G, h, I, k, q, r, s, W, Z
495 3b. SUMMARY_Area_Commands
496 l, m, t, 1
497 3c. TASK_Area_Commands
498 Appearance: b, x, y, z
499 Content: c, f, H, o, S, u
500 Size: #, i, n
501 Sorting: <, >, F, O, R
502 3d. COLOR_Mapping
503 <Ret>, a, B, b, H, M, q, S, T, w, z, 0 - 7
504 4b. COMMANDS_for_Windows
505 -, _, =, +, A, a, G, g, w
506
507
508 3a. GLOBAL Commands
509 The global interactive commands are always available in both
510 full-screen mode and alternate-display mode. However, some of
511 these interactive commands are not available when running in
512 'Secure mode'.
513
514 If you wish to know in advance whether or not your top has been
515 secured, simply ask for help and view the system summary on the
516 second line.
517
518
519 <Enter> or <Space> :Refresh_Display
520 These commands do nothing, they are simply ignored. How‐
521 ever, they will awaken top and following receipt of any
522 input the entire display will be repainted.
523
524 Use either of these keys if you have a large delay interval
525 and wish to see current status,
526
527
528 ´?´ or ´h´ :Help
529 There are two help levels available. The first will pro‐
530 vide a reminder of all the basic interactive commands. If
531 top is secured, that screen will be abbreviated.
532
533 Typing 'h' or '?' on that help screen will take you to help
534 for those interactive commands applicable to alternate-dis‐
535 play mode.
536
537
538 ´=´ :Exit_Task_Limits
539 Removes restrictions on which tasks are shown. This com‐
540 mand will reverse any 'i' (idle tasks) and 'n' (max tasks)
541 commands that might be active. It also provides for an
542 'exit' from PID monitoring. See the '-p' command-line
543 option for a discussion of PID monitoring.
544
545 When operating in alternate-display mode this command has a
546 slightly broader meaning.
547
548
549 ´A´ :Alternate_Display_Mode_toggle
550 This command will switch between full-screen mode and
551 alternate-display mode. See topic 4. ALTERNATE-DISPLAY
552 Mode and the 'G' interactive command for insight into ´cur‐
553 rent' windows and field groups.
554
555
556 ´B´ :Bold_Disable/Enable_toggle
557 This command will influence use of the 'bold' terminfo
558 capability and alters both the summary area and task area
559 for the ´current' window. While it is intended primarily
560 for use with dumb terminals, it can be applied anytime.
561
562 Note: When this toggle is On and top is operating in mono‐
563 chrome mode, the entire display will appear as normal text.
564 Thus, unless the 'x' and/or 'y' toggles are using reverse
565 for emphasis, there will be no visual confirmation that
566 they are even on.
567
568
569 * ´d´ or ´s´ :Change_Delay_Time_interval
570 You will be prompted to enter the delay time, in seconds,
571 between display updates.
572
573 Fractional seconds are honored, but a negative number is
574 not allowed. Entering 0 causes (nearly) continuous
575 updates, with an unsatisfactory display as the system and
576 tty driver try to keep up with top's demands. The delay
577 value is inversely proportional to system loading, so set
578 it with care.
579
580 If at any time you wish to know the current delay time,
581 simply ask for help and view the system summary on the sec‐
582 ond line.
583
584
585 ´G´ :Choose_Another_Window/Field_Group
586 You will be prompted to enter a number between 1 and 4 des‐
587 ignating the window/field group which should be made the
588 ´current' window. You will soon grow comfortable with
589 these 4 windows, especially after experimenting with alter‐
590 nate-display mode.
591
592
593 ´I´ :Irix/Solaris_Mode_toggle
594 When operating in 'Solaris mode' ('I' toggled Off), a
595 task's cpu usage will be divided by the total number of
596 CPUs. After issuing this command, you'll be informed of
597 the new state of this toggle.
598
599
600 ´u´ :select a user
601 You will be prompted for a UID or username. Only processes
602 belonging to the selected user will be displayed. This
603 option matches on the effective UID.
604
605
606 ´U´ :select a user
607 You will be prompted for a UID or username. Only processes
608 belonging to the selected user will be displayed. This
609 option matches on the real, effective, saved, and filesys‐
610 tem UID.
611
612
613 * ´k´ :Kill_a_task
614 You will be prompted for a PID and then the signal to send.
615 The default signal, as reflected in the prompt, is SIGTERM.
616 However, you can send any signal, via number or name.
617
618 If you wish to abort the kill process, do one of the fol‐
619 lowing depending on your progress:
620 1) at the pid prompt, just press <Enter>
621 2) at the signal prompt, type 0
622
623
624 ´q´ :Quit
625
626
627 * ´r´ :Renice_a_Task
628 You will be prompted for a PID and then the value to nice
629 it to. Entering a positive value will cause a process to
630 lose priority. Conversely, a negative value will cause a
631 process to be viewed more favorably by the kernel.
632
633
634 ´W´ :Write_the_Configuration_File
635 This will save all of your options and toggles plus the
636 current display mode and delay time. By issuing this com‐
637 mand just before quitting top, you will be able restart
638 later in exactly that same state.
639
640
641 ´Z´ :Change_Color_Mapping
642 This key will take you to a separate screen where you can
643 change the colors for the ´current' window, or for all win‐
644 dows. For details regarding this interactive command see
645 topic 3d. COLOR Mapping.
646
647
648 * The commands shown with an asterisk ('*') are not available in
649 'Secure mode', nor will they be shown on the level-1 help
650 screen.
651
652
653 3b. SUMMARY Area Commands
654 The summary area interactive commands are always available in both
655 full-screen mode and alternate-display mode. They affect the
656 beginning lines of your display and will determine the position of
657 messages and prompts.
658
659 These commands always impact just the ´current' window/field
660 group. See topic 4. ALTERNATE-DISPLAY Mode and the 'G' interac‐
661 tive command for insight into ´current' windows and field groups.
662
663
664 ´l´ :Toggle_Load_Average/Uptime -- On/Off
665 This is also the line containing the program name (possibly
666 an alias) when operating in full-screen mode or the ´cur‐
667 rent' window name when operating in alternate-display mode.
668
669
670 ´m´ :Toggle_Memory/Swap_Usage -- On/Off
671 This command affects two summary area lines.
672
673
674 ´t´ :Toggle_Task/Cpu_States -- On/Off
675 This command affects from 2 to many summary area lines,
676 depending on the state of the '1' toggle and whether or not
677 top is running under true SMP.
678
679
680 ´1´ :Toggle_Single/Separate_Cpu_States -- On/Off
681 This command affects how the 't' command's Cpu States por‐
682 tion is shown. Although this toggle exists primarily to
683 serve massively-parallel SMP machines, it is not restricted
684 to solely SMP environments.
685
686 When you see 'Cpu(s):' in the summary area, the '1' toggle
687 is On and all cpu information is gathered in a single line.
688 Otherwise, each cpu is displayed separately as: 'Cpu0,
689 Cpu1, ...'
690
691
692 Note: If the entire summary area has been toggled Off for any win‐
693 dow, you would be left with just the message line. In that way,
694 you will have maximized available task rows but (temporarily) sac‐
695 rificed the program name in full-screen mode or the ´current' win‐
696 dow name when in alternate-display mode.
697
698
699 3c. TASK Area Commands
700 The task area interactive commands are always available in
701 full-screen mode.
702
703 The task area interactive commands are never available in alter‐
704 nate-display mode if the ´current' window's task display has been
705 toggled Off (see topic 4. ALTERNATE-DISPLAY Mode).
706
707
708 APPEARANCE of task window
709 The following commands will also be influenced by the state of
710 the global 'B' (bold disable) toggle.
711
712
713 ´b´ :Bold/Reverse_toggle
714 This command will impact how the 'x' and 'y' toggles are
715 displayed. Further, it will only be available when at
716 least one of those toggles is On.
717
718
719 ´x´ :Column_Highlight_toggle
720 Changes highlighting for the current sort field. You prob‐
721 ably don't need a constant visual reminder of the sort
722 field and top hopes that you always run with 'column high‐
723 light' Off, due to the cost in path-length.
724
725 If you forget which field is being sorted this command can
726 serve as a quick visual reminder.
727
728
729 ´y´ :Row_Highlight_toggle
730 Changes highlighting for "running" tasks. For additional
731 insight into this task state, see topic 2a. DESCRIPTIONS of
732 Fields, Process Status.
733
734 Use of this provision provides important insight into your
735 system's health. The only costs will be a few additional
736 tty escape sequences.
737
738
739 ´z´ :Color/Monochrome_toggle
740 Switches the ´current' window between your last used color
741 scheme and the older form of black-on-white or white-on-
742 black. This command will alter both the summary area and
743 task area but does not affect the state of the 'x', 'y' or
744 'b' toggles.
745
746
747 CONTENT of task window
748 ´c´ :Command_Line/Program_Name_toggle
749 This command will be honored whether or not the 'Command'
750 column is currently visible. Later, should that field come
751 into view, the change you applied will be seen.
752
753 ´f´ and ´o´ :Fields_select or Order_fields
754 These keys display separate screens where you can change
755 which fields are displayed and their order. For additional
756 information on these interactive commands see topic 2b.
757 SELECTING and ORDERING Columns.
758
759 ´H´ :Threads_toggle
760 When this toggle is On, all individual threads will be dis‐
761 played. Otherwise, top displays a summation of all threads
762 in a process.
763
764 ´S´ :Cumulative_Time_Mode_toggle
765 When 'Cumulative mode' is On, each process is listed with
766 the cpu time that it and its dead children have used.
767
768 When Off, programs that fork into many separate tasks will
769 appear less demanding. For programs like 'init' or a shell
770 this is appropriate but for others, like compilers, perhaps
771 not. Experiment with two task windows sharing the same
772 sort field but with different 'S' states and see which rep‐
773 resentation you prefer.
774
775 After issuing this command, you'll be informed of the new
776 state of this toggle. If you wish to know in advance
777 whether or not 'Cumulative mode' is in effect, simply ask
778 for help and view the window summary on the second line.
779
780 ´u´ :Show_Specific_User_Only
781 You will be prompted to enter the name of the user to dis‐
782 play. Thereafter, in that task window only matching User
783 ID's will be shown, or possibly no tasks will be shown.
784
785 Later, if you wish to monitor all tasks again, re-issue
786 this command but just press <Enter> at the prompt, without
787 providing a name.
788
789 SIZE of task window
790 ´i´ :Idle_Processes_toggle
791 Displays all tasks or just active tasks. When this toggle
792 is Off, idled or zombied processes will not be displayed.
793
794 If this command is applied to the last task display when in
795 alternate-display mode, then it will not affect the win‐
796 dow's size, as all prior task displays will have already
797 been painted.
798
799 ´n´ or ´#´ :Set_Maximum_Tasks
800 You will be prompted to enter the number of tasks to dis‐
801 play. The lessor of your number and available screen rows
802 will be used.
803
804 When used in alternate-display mode, this is the command
805 that gives you precise control over the size of each cur‐
806 rently visible task display, except for the very last. It
807 will not affect the last window's size, as all prior task
808 displays will have already been painted.
809
810 Note: If you wish to increase the size of the last visible
811 task display when in alternate-display mode, simply
812 decrease the size of the task display(s) above it.
813
814 SORTING of task window
815 For compatibility, this top supports most of the former top sort
816 keys. Since this is primarily a service to former top users,
817 these commands do not appear on any help screen.
818 command sorted field supported
819 A start time (non-display) No
820 M %MEM Yes
821 N PID Yes
822 P %CPU Yes
823 T TIME+ Yes
824
825 Before using any of the following sort provisions, top suggests
826 that you temporarily turn on column highlighting using the 'x'
827 interactive command. That will help ensure that the actual sort
828 environment matches your intent.
829
830 The following interactive commands will only be honored when the
831 current sort field is visible. The sort field might not be vis‐
832 ible because:
833 1) there is insufficient Screen Width
834 2) the 'f' interactive command turned it Off
835
836 ´<´ :Move_Sort_Field_Left
837 Moves the sort column to the left unless the current sort
838 field is the first field being displayed.
839
840 ´>´ :Move_Sort_Field_Right
841 Moves the sort column to the right unless the current sort
842 field is the last field being displayed.
843
844 The following interactive commands will always be honored
845 whether or not the current sort field is visible.
846
847 ´F´ or ´O´ :Select_Sort_Field
848 These keys display a separate screen where you can change
849 which field is used as the sort column.
850
851 If a field is selected which was not previously being dis‐
852 played, it will be forced On when you return to the top
853 display. However, depending upon your screen width and the
854 order of your fields, this sort field may not be dis‐
855 playable.
856
857 This interactive command can be a convenient way to simply
858 verify the current sort field, when running top with column
859 highlighting turned Off.
860
861 ´R´ :Reverse/Normal_Sort_Field_toggle
862 Using this interactive command you can alternate between
863 high-to-low and low-to-high sorts.
864
865 Note: Field sorting uses internal values, not those in column
866 display. Thus, the TTY and WCHAN fields will violate strict
867 ASCII collating sequence.
868
869 3d. COLOR Mapping
870 When you issue the 'Z' interactive command, you will be presented
871 with a separate screen. That screen can be used to change the
872 colors in just the ´current' window or in all four windows before
873 returning to the top display.
874
875 Available interactive commands
876 4 upper case letters to select a target
877 8 numbers to select a color
878 normal toggles available
879 'B' :bold disable/enable
880 'b' :running tasks "bold"/reverse
881 'z' :color/mono
882 other commands available
883 'a'/'w' :apply, then go to next/prior
884 <Enter> :apply and exit
885 'q' :abandon current changes and exit
886
887 If your use 'a' or 'w' to cycle the targeted window, you will have
888 applied the color scheme that was displayed when you left that
889 window. You can, of course, easily return to any window and reap‐
890 ply different colors or turn colors Off completely with the 'z'
891 toggle.
892
893 The Color Mapping screen can also be used to change the ´current'
894 window/field group in either full-screen mode or alternate-display
895 mode. Whatever was targeted when 'q' or <Enter> was pressed will
896 be made current as you return to the top display.
897
898
900 4a. WINDOWS Overview
901 Field Groups/Windows:
902 In full-screen mode there is a single window represented by
903 the entire screen. That single window can still be changed
904 to display 1 of 4 different field groups (see the 'G'
905 interactive command, repeated below). Each of the 4 field
906 groups has a unique separately configurable summary area
907 and its own configurable task area.
908
909 In alternate-display mode, those 4 underlying field groups
910 can now be made visible simultaneously, or can be turned
911 Off individually at your command.
912
913 The summary area will always exist, even if it's only the
914 message line. At any given time only one summary area can
915 be displayed. However, depending on your commands, there
916 could be from zero to four separate task displays currently
917 showing on the screen.
918
919 Current Window:
920 The ´current' window is the window associated with the sum‐
921 mary area and the window to which task related commands are
922 always directed. Since in alternate-display mode you can
923 toggle the task display Off, some commands might be
924 restricted for the ´current' window.
925
926 A further complication arises when you have toggled the
927 first summary area line Off. With the loss of the window
928 name (the 'l' toggled line), you'll not easily know what
929 window is the ´current' window.
930
931 4b. COMMANDS for Windows
932 ´-´ and ´_´ :Show/Hide_Window(s)_toggles
933 The '-' key turns the ´current' window's task display On
934 and Off. When On, that task area will show a minimum of
935 the columns header you've established with the 'f' and 'o'
936 commands. It will also reflect any other task area
937 options/toggles you've applied yielding zero or more tasks.
938
939 The '_' key does the same for all task displays. In other
940 words, it switches between the currently visible task dis‐
941 play(s) and any task display(s) you had toggled Off. If
942 all 4 task displays are currently visible, this interactive
943 command will leave the summary area as the only display
944 element.
945
946 * ´=´ and ´+´ :Equalize_(re-balance)_Window(s)
947 The '=' key forces the ´current' window's task display to
948 be visible. It also reverses any 'i' (idle tasks) and 'n'
949 (max tasks) commands that might be active.
950
951 The '+' key does the same for all windows. The four task
952 displays will reappear, evenly balanced. They will also
953 have retained any customizations you had previously
954 applied, except for the 'i' (idle tasks) and 'n' (max
955 tasks) commands.
956
957 * ´A´ :Alternate_Display_Mode_toggle
958 This command will switch between full-screen mode and
959 alternate-display mode.
960
961 The first time you issue this command, all four task dis‐
962 plays will be shown. Thereafter when you switch modes, you
963 will see only the task display(s) you've chosen to make
964 visible.
965
966 * ´a´ and ´w´ :Next_Window_Forward/Backward
967 This will change the ´current' window, which in turn
968 changes the window to which commands are directed. These
969 keys act in a circular fashion so you can reach any desired
970 ´current' window using either key.
971
972 Assuming the window name is visible (you have not toggled
973 'l' Off), whenever the ´current' window name loses its
974 emphasis/color, that's a reminder the task display is Off
975 and many commands will be restricted.
976
977 * ´G´ :Choose_Another_Window/Field_Group
978 You will be prompted to enter a number between 1 and 4 des‐
979 ignating the window/field group which should be made the
980 ´current' window.
981
982 In full-screen mode, this command is necessary to alter the
983 ´current' window. In alternate-display mode, it is simply
984 a less convenient alternative to the 'a' and 'w' commands.
985
986 ´g´ :Change_Window/Field_Group_Name
987 You will be prompted for a new name to be applied to the
988 ´current' window. It does not require that the window name
989 be visible (the 'l' toggle to be On).
990
991 * The interactive commands shown with an asterisk ('*') have use
992 beyond alternate-display mode.
993 ´=', 'A', 'G' are always available
994 ´a', 'w' act the same when color mapping
995
996
998 5a. SYSTEM Configuration File
999 The presence of this file will influence which version of the
1000 'help' screen is shown to an ordinary user. More importantly, it
1001 will limit what ordinary users are allowed to do when top is run‐
1002 ning. They will not be able to issue the following commands.
1003 k Kill a task
1004 r Renice a task
1005 d or s Change delay/sleep interval
1006
1007 The system configuration file is not created by top. Rather, you
1008 create this file manually and place it in the /etc directory. Its
1009 name must be 'toprc' and must have no leading '.' (period). It
1010 must have only two lines.
1011
1012 Here is an example of the contents of /etc/toprc:
1013 s # line 1: 'secure' mode switch
1014 5.0 # line 2: 'delay' interval in seconds
1015
1016 5b. PERSONAL Configuration File
1017 This file is written as '$HOME/.your-name-4-top' + 'rc'. Use the
1018 'W' interactive command to create it or update it.
1019
1020 Here is the general layout:
1021 global # line 1: the program name/alias notation
1022 " # line 2: id,altscr,irixps,delay,curwin
1023 per ea # line a: winname,fieldscur
1024 window # line b: winflags,sortindx,maxtasks
1025 " # line c: summclr,msgsclr,headclr,taskclr
1026
1027 If the $HOME variable is not present, top will try to write the
1028 personal configuration file to the current directory, subject to
1029 permissions.
1030
1031
1033 Many of these 'tricks' work best when you give top a scheduling
1034 boost. So plan on starting him with a nice value of -10, assuming
1035 you've got the authority.
1036
1037 6a. Kernel Magic
1038 For these stupid tricks, top needs full-screen mode.
1039
1040 -*- The user interface, through prompts and help, intentionally
1041 implies that the delay interval is limited to tenths of a
1042 second. However, you're free to set any desired delay. If
1043 you want to see Linux at his scheduling best, try a delay of
1044 .09 seconds or less.
1045
1046 For this experiment, under x-windows open an xterm and maxi‐
1047 mize it. Then do the following:
1048 . provide a scheduling boost and tiny delay via:
1049 nice -n -10 top -d.09
1050 . keep sorted column highlighting Off to minimize
1051 path length
1052 . turn On reverse row highlighting for emphasis
1053 . try various sort columns (TIME/MEM work well),
1054 and normal or reverse sorts to bring the most
1055 active processes into view
1056
1057 What you'll see is a very busy Linux doing what he's always
1058 done for you, but there was no program available to illus‐
1059 trate this.
1060
1061 -*- Under an xterm using 'white-on-black' colors, try setting
1062 top's task color to black and be sure that task highlighting
1063 is set to bold, not reverse. Then set the delay interval to
1064 around .3 seconds.
1065
1066 After bringing the most active processes into view, what
1067 you'll see are the ghostly images of just the currently run‐
1068 ning tasks.
1069
1070 -*- Delete the existing rcfile, or create a new symlink. Start
1071 this new version then type 'T' (a secret key, see topic 3c.
1072 TASK Area Commands, Sorting) followed by 'W' and 'q'.
1073 Finally, restart the program with -d0 (zero delay).
1074
1075 Your display will be refreshed at three times the rate of the
1076 former top, a 300% speed advantage. As top climbs the TIME
1077 ladder, be as patient as you can while speculating on whether
1078 or not top will ever reach the top.
1079
1080 6b. Bouncing Windows
1081 For these stupid tricks, top needs alternate-display mode.
1082
1083 -*- With 3 or 4 task displays visible, pick any window other than
1084 the last and turn idle processes Off. Depending on where you
1085 applied 'i', sometimes several task displays are bouncing and
1086 sometimes it's like an accordion, as top tries his best to
1087 allocate space.
1088
1089 -*- Set each window's summary lines differently: one with no mem‐
1090 ory; another with no states; maybe one with nothing at all,
1091 just the message line. Then hold down 'a' or 'w' and watch a
1092 variation on bouncing windows -- hopping windows.
1093
1094 -*- Display all 4 windows and for each, in turn, set idle pro‐
1095 cesses to Off. You've just entered the "extreme bounce"
1096 zone.
1097
1098 6c. The Big Bird Window
1099 This stupid trick also requires alternate-display mode.
1100
1101 -*- Display all 4 windows and make sure that 1:Def is the ´cur‐
1102 rent' window. Then, keep increasing window size until the
1103 all the other task displays are "pushed out of the nest".
1104
1105 When they've all been displaced, toggle between all visi‐
1106 ble/invisible windows. Then ponder this:
1107 is top fibbing or telling honestly your imposed truth?
1108
1109
1111 Send bug reports to:
1112 Albert D. Cahalan, <albert@users.sf.net>
1113
1114 The top command calculates Cpu(s) by looking at the change in CPU
1115 time values between samples. When you first run it, it has no pre‐
1116 vious sample to compare to, so these initial values are the per‐
1117 centages since boot. It means you need at least two loops or you
1118 have to ignore summary output from the first loop. This is prob‐
1119 lem for example for batch mode. There is a possible workaround if
1120 you define the CPULOOP=1 environment variable. The top command
1121 will be run one extra hidden loop for CPU data before standard
1122 output.
1123
1125 The original top was written by Roger Binns, based on Branko
1126 Lankester's <lankeste@fwi.uva.nl> ps program.
1127
1128 Robert Nation <nation@rocket.sanders.lockheed.com> adapted it for
1129 the proc file system.
1130
1131 Helmut Geyer <Helmut.Geyer@iwr.uni-heidelberg.de> added support
1132 for configurable fields.
1133
1134 Plus many other individuals contributed over the years.
1135
1136
1138 This entirely new and enhanced replacement was written by:
1139 Jim / James C. Warner, <warnerjc@worldnet.att.net>
1140
1141 With invaluable help from:
1142 Albert D. Cahalan, <albert@users.sf.net>
1143 Craig Small, <csmall@small.dropbear.id.au>
1144
1145
1147 free(1), ps(1), uptime(1), atop(1), slabtop(1), vmstat(8), w(1).
1148
1149
1150
1151
1152
1153
1154Linux September 2002 TOP(1)