Objective
Understand how to use the top command to display processor activity of your Linux machine and also display running tasks in real-time.
Prerequisites
A machine running Linux.
Steps
Step 1: Displaying Top Command
Upon entering the top command, several information such as tasks, memory, cpu and swap will be displayed.
To quit the window, press ‘q‘.
Step 2: Sorting Output
In the top command display, you can sort the output based on the field, (e.g. PID, CPU, MEM, etc.)
To do this, press ‘o’ inside the command display. Then, type the field you want to sort the output based on (e.g. CPU). Afterwards, press Enter
Step 3: Terminate a Process
In the top command display, you can also terminate a process by force, similar to what you would do in Windows Task Manager.
To do this, press ‘k’ and enter the PID of the process that you want to terminate.
Step 4: Entering Top Help Display
You can view all the interactive command in the top display and see their details. Do this by pressing ‘h’ inside the top display.