1. Show Processes Sorted by any Top Output Column – Press O

By default top command displays the processes in the order of CPU usage.  When the top command is running, press M (upper-case) to display processes sorted by memory usage as shown below.


Fig: Press M to sort by memory usage – Unix top command

To sort top output by any column, Press O (upper-case O) , which will display all the possible columns that you can sort by as shown below.

When the linux top command is running, Press R, which does the sort in reverse order.

2. Kill a Task Without Exiting From Top – Press k

Once you’ve located a process that needs to be killed, press ‘k’ which will ask for the process id, and signal to send.  If you have the privilege to kill that particular PID, it will get killed successfully.

3. Renice a Unix Process Without Exiting From Top – Press r

Press r, if you want to just change the priority of the process (and not kill the process). This will ask PID for renice, enter the PID and priority.

4. Display Selected User in Top Output Using top -u

Use top -u to display a specific user processes only in the top command output.

While unix top command is running, press u which will ask for username as shown below.

Display Only Specific Process with Given PIDs Using top -p

Use top -p as shown below to display specific PIDs.

5. Display All CPUs / Cores in the Top Output – Press 1 (one)

Top output by default shows CPU line for all the CPUs combined together as shown below.

Press 1 (one), when the top command is running, which will break the CPU down and show details for all the individual CPUs running on the system as shown below.

6. Refresh Unix Top Command Output On demand (or) Change Refresh Interval

By default, linux top command updates the output every 3.0 seconds. When you want to update the output on-demand, press space bar.

To change the output update frequency, press d in interactive mode, and enter the time in seconds as shown below.

7. Highlight Running Processes in the Linux Top Command Output – Press z or b

Press z or b, which will highlight all running process as shown below.

Fig: Ubuntu Linux – top command highlights running process

8. Display Absolute Path of the Command and its Arguments – Press c

Press c which will show / hide command absolute path, and arguments as shown below.

9. Quit Top Command After a Specified Number of Iterations Using top -n

Until you press q, top continuously displays the output. If you would like to view only a certain iteration and want the top to exit automatically use -n option as shown below.

The following example will show 2 iterations of unix top command output and exit automatically

10. Executing Unix Top Command in Batch Mode

If you want to execute top command in the batch mode use option -b as shown below.

Note: This option is very helpful when you want to capture the unix top command output to a readable text file as we discussed earlier.

11. Split Top Output into Multiple Panels – Press A

To display multiple views of top command output on the terminal, press A. You can cycle through these windows using ‘a’. This is very helpful, when you can sort the output on multiple windows using different top output columns.

12. Get Top Command Help from Command Line and Interactively

Get a quick command line option help using top -h as shown below.

Press h while top command is running, which will display help for interactive top commands.

13. Decrease Number of Processes Displayed in Top Output – Press n

Press n in the Interactive mode, which prompts for a number and shows only that. Following example will display only 2 process as a time.

14. Toggle Top Header to Increase Number of Processes Displayed

By default top displays total number process based on the window height. If you like to see additional process you might want to eliminate some of the top header information.

Following is the default header information provided by top.

  • Press l – to hide / show the load average. 1st header line.
  • Press t – to hide / show the CPU states. 2nd and 3rd header line.
  • Press m – to hide / show the memory information. 4th and 5th line.

15. Save Top Configuration Settings – Press W

If you’ve made any interactive top command configurations suggested in the above examples, you might want to save those for all future top command output. Once you’ve saved the top configuration, next time when you invoke the top command all your saved top configuration options will be used automatically.

To save the top configuration, press W, which will write the configuration files to ~/.toprc. This will display the write confirmation message as shown below.