The “top” command provides a dynamic real-time view of a running system. It can display system summary information as well as a list of processes or threads currently being managed by the Linux kernel.
The types of system summary information shown and the types, order and size of information displayed for processes are all user configurable and that configuration can be made persistent across restarts.
Here are some top command examples.
If we type ‘top’ in terminal, this is how our output looks. By default, top command displays the output sorted by CPU usage.
sk@sk:~$ top
1. Display processes sorted by memory usage
To display the top command output sorted by memory usage type uppercase letter “M”
2. Display all CPU’s in top command output
To display all CPU’s (cores) in the top output press “1”(Number 1).
3. Display the path’s of commands and arguments
To display the path’s of the command press lowercase “c”.
4. Split top command output into multiple segments
To split out the top command output into segments press uppercase “A”.
5. Kill a process without quitting from top
To kill a process without exiting from top command press lowercase “k”. Enter the PID of process to quit.
6. Display particular user output
To display output sorted by a particular user, use the parameter “-u”.
sk@sk:~$ top -u sk
7. Highlight running processes
To highlight the running processes in the top command output, press “z”.
8. Change refresh interval of top command
By default, the top command updates the output every 3 seconds. You can change the interval by pressing “s” key. It will ask you to enter the new time interval.
9. View help screen without quitting Top command
To view help screen interactively without exiting from top command press “h” or “?”. Press any key to exit from the help screen.
10. Save top command settings
If you want to save the changes you have made using the above commands, press uppercase “W”. It saves the settings to ~/.toprc. The changes will be used automatically later.
For more information to know about top command use man command.
sk@sk:~$ man top
Alternatively you can use “htop” command. It is even better and more powerful than top command.