In this tutorial, we'll show you how to use top to monitor your processes in real time. Top gives an overview of what cpu and memory resources the processes on your system are using.
To run top, simply enter the command:
topThis will display the top few processes (sorted by CPU usage). The display is updated periodically (default is every 3 seconds) to ensure the info displayed is up to date. This page refresh rate can be controlled by hitting either 'd' or 's' and entering the number of seconds you wish to use.
To highlight the values in the summary aread, hit "B" (i.e. for Bold).
Saving Your Changes
Before continuing any further with customising top's look and feel for your purposes, be aware that you must save any changes otherwise top will discard them when you exit (exit by typing "q").
To save any changes you make just hit "W".
Tweaking the Summary Area
The first area to the top of the screen while viewing the top program is called the summary area.
You can toggle which bits of this are included in the display.
- To toggle the showing of load average and uptime, hit "l".
- To toggle memory and swap space information, hit "m".
- To toggle task data and cpu state information, hit "t".
- To toggle showing each cpu, hit "1".
Different Display Types
There are four display types (where each display type shows different column fields, column ordering, and sort field).
The default display type is 1. To change the display type, hit "G" followed by the number (1 - 4).
These are the column headers available in each display mode:
Mode 1 will show the following columns in the display:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMANDMode 2 will show:
PID PPID TIME+ %CPU %MEM PR NI S VIRT SWAP RES UID COMMANDMode 3 will show:
PID %MEM VIRT SWAP RES CODE DATA SHR nFLT nDRT S PR NI %CPU COMMANDMode 4 will show:
PID PPID UID USER RUSER TTY TIME+ %CPU %MEM S COMMAND
There is an "Alternate Mode" that you can use which shows the top few from each display type/mode. To use the alternate mode just hit "A".
Sort Related Options
You can change which field gets used for the sort order by hitting "F" or "O".
The following options are available:
Choose one by hitting the appropriate letter, then hit return.
The sort order itself can be changed (i.e.largest to smallest -> smallest to largest) by hitting "R".
Also, you can highlight the column of the field used for sorting by hitting "x"
Tweaking the Task Area
To toggle the showing of the command line options used to start the applications, hit "c".
To toggle whether to show threads or not, hit "H".
The use of cumulative time (total cpu time used by the process and its dead children) can be turned on by hitting "S".
You can toggle colour on/off by hitting "z"
You can change the colours used by top by hitting "Z". You'll be shown the options as per the image below:
Simply hit the letter for the target area you want to change the colour of, then hit the number of the colour.You can save your changes immeadiately (by hitting "a" or "w"), or afterwards by hitting "W" before you exit top.
This is a quick reference as per man page.
|B||bold summary headings|
|G||choose 1-4 to get different displays|
|W||write current settinigs to its config file.|
|l||toggle show load average/uptime|
|m||toggle show memory and swap space info|
|t||toggle task data / cpu states|
|1||toggle show all cpu's|
|c||show command line for program|
|H||toggle show threads|
|x||highlite the sort field column|
|y||row highlight the running task|
|F||change sort field|
|O||change sort field|
See the man page for a full list of options and configurables.
A big thank you to James C. Warner, Albert D. Cahalan, and Craig Small for this helpful tool .