Top Command is one of the important tool for system administrator. TOP command in LINUX displays the running process on the system and also the list of task which is currently managed by the server. It is a non- interactive command. System summary information as well as list of threads currently managed by the Linux Kernel can be known with the TOP command.
The syntax of top command is:

Code:
top [options]
Display Process - Default TOP command:

To get a overall spot of the running process, Just run the TOP command simply.
The Screen contains loads of information like task, memory, CPU, swap etc.
The header area will show the memory usage, cpu usage, uptime, average load time.
The other process will show various data with specific columns, Some of the columns are

PID - Process ID
USER - The system user account running the process.
%CPU - CPU usage by the process.
%MEM - Memory usage by the process
COMMAND - The command (executable file) of the process
top1.png


Sorting field with field letter:

Using TOP command, sort the system's memory consuming part.

There are various TOP commands to find process consuming memory in the system.
  • Press M key - the process list by memory usage.
  • Press 'P' - to sort the process list by cpu usage.
  • Filter with -O
  • Press Shift+O to Field letter sort. With this, various criteria’s like process name, memory, CPU usage can be filtered.
  • After that Press 'a' letter to sort process within PID.
  • Press q to quit
Showing UP Running Process:
Highlighting the running process in different color will help in more understanding. Press 'z' to show running process in Top command as color to identify it easily.
Display Full Command Path:
Press 'c' in running TOP command, which results and displays absolute path of running process along with commands column.

Show/Hide columns:
  • TOP command displays only few columns rather it hide many columns. So there helps the 'f', Press 'f' to remove or add a particular column or change the order.
  • The Fields which are already displays will be marked as * or bold.
  • UP/DOWN arrow keys are used to navigate in the list.
  • Press 'd' to toggle in the display of that field.
  • Press 'q' Once completed.
To display particular user process:

You have to use "u" command with specific user process details.

Code:
# top -u mysql
top2.png


Set Screen Refresh Interval:

Pressing 'd' option in running TOP command used to change default delay. The default screen refresh interval is 3.0 seconds it is changed as desired by 'd' command.

To show absolute path of particular process:

For the absolute path hit "c" in running top command, it will show the path.

top3.png


Kill the process Argument 'k':

To kill the process after finding PID can be done by pressing 'k'. This helps to kill the process without exiting from top window.

Save the Results:

Code:
$ top -n 1 -b > top-output.txt
This command is used to save the running top command results to a file /root/.toprc as output.
Hide/Show:

You can hide or show the information in running top command, this helps more processes visible in list.
  • Press 'l' to hide the load average information.
  • Press 'm' to hide the memory information.
  • Press 't' to hide cpu and task information.
Top Command – Help:
Press ‘h‘ option to access the top command help.

Top Command – Exit:
Press 'q' to stop refreshing outputs of running top commands. You can also set automatically exit after certain repetition.

The command to Exit Top command is as follows
Code:
$ top -n 10
Author
bhawanisingh
Views
3,371
First release
Last update
Rating
0.00 star(s) 0 ratings
Top