16 top command examples in Linux [Monitor Linux Processes]

s2 0

In our previous articles, we covered the basics of the ls and cat commands. In this article, we’ll try to explore the topmost command, which is one of the most commonly used commands in our daily system administration tasks.

the above Command (table of processes) shows the processor activity of your Linux box and also shows tasks managed by the kernel in real time. It also shows information about CPU and memory usage from a list of running processes.

You might also be interested in the following tutorials :

  • Htop – An interactive process viewer for Linux
  • Iotop – Monitor Linux hard drive I / O activity and usage on a per process basis
  • bmon – A powerful network bandwidth monitor for Linux
  • Find the top 15 processes by memory usage in Linux

1. List all running Linux processes

To list all running Linux processes, just enter above on the command line for information on how to run it tasks, reminder, Central processor, and To deceive. Press ‘q“To close the window.

# top
View running Linux processes

2. Sort Linux processes by PID

To sort all running Linux processes by process ID, press M and T Key.

List of Linux processes by PID
List of Linux processes by PID

3. Sort Linux processes according to memory and CPU usage

To sort all running Linux processes by memory usage, press M and P Key.

Sort Linux processes by memory CPU usage
Sort Linux processes by memory CPU usage

4. Sort Linux processes by runtime

To sort all running Linux processes by runtime, press M and T Key.

Sort Linux processes by runtime
Sort Linux processes by runtime

5. View Linux processes by specific users

To display all user-specific information on running processes, use the -u Option will list specifically user Procedural details.

# top -u tecmint
List Linux processes by specific users
List Linux processes by specific users

6. Select the running process in Top

Press ‘z‘Option shows the running process in color, which can help you to easily identify the running process.

Highlight Linux Process
Highlight Linux Process

7. List the absolute path of the Linux processes running

Press ‘c‘in the running command top shows the absolute path of the running process.

List Linux processes by path
List Linux processes by path

8. Set the update interval for the command above

By default, the screen refresh interval is set to 3.0 Seconds, the same can be changed by pressing the ‘button.d‘Option when executing the top command to set the desired interval time.

Set the update time of the command above
Set the update time of the command above

9. End the running Linux process with the top command

You can kill a process after finding the process’s PID by clicking ‘k‘when running the top command without closing the top window, as shown below.

End the Linux process with PID
End the Linux process with PID

10. Sort Linux processes according to CPU usage

To sort all running processes by CPU usage, just press Shift+P Key.

Sort Linux processes by CPU usage
Sort Linux processes by CPU usage

11. Renice a Linux process

You can use the … ‘r‘Option to change the priority of the process also called Renice.

Renice Linux process
Renice Linux process

12. Check the Linux CPU cores

To list the load information of your CPU cores, just press 1 to list the CPU core details.

List Linux CPU cores
List Linux CPU cores

13. Save the most important command results to a file

How to save the output of the executed top command to a file /root/.toprc use the following command.

# top -n 1 -b > top-output.txt

14. List Linux idle processes

Press 'i' to get the list of inactive / sleeping processes.

List Linux idle processes
List Linux idle processes

15. How to get help for the top commands

Press the ‘h‘for supreme command.

Linux Top Command Help
Linux Top Command Help

16. Exit the top command after a certain repetition

The output of the top command is updated until you ‘q‘. The following command will automatically exit after 10 repetitions.

# top -n 10

There are a number of arguments for finding out more about that above Command, you can refer to the above Command. Please share if you find this article useful or share your thoughts using our comments box below.