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