What is the purpose of the top command and how can you use it to stop a process?

The very basic commands and easily implementable ones are known to be the Linux Top commands. These are used to show the processes and their details. It shows the summary of information of all the running processes in the system. This interface of the top command is divided into two parts. One shows the stats value, whereas the lower one shows the list of running processes.

Display all the processes

This shows the process ids and their information. The information like tasks, CPU, and memory is also displayed. The window of the top command can be quit by using the key ‘q’.

What is the purpose of the top command and how can you use it to stop a process?

Processes of the particular user

If we want to know the process of a specific user, we will use the below command to know the details.

As we have a user name aqsayasin so we will try this one to examine all process details.

What is the purpose of the top command and how can you use it to stop a process?

Color the process

To identify or clarify, the running process can be highlighted or colored by using a specific keyword, “z”. This will support identifying the running process very easily. You need to use the command while the process is running. Because once you have quit the process detail and then apply the color. That will never work. It will only work in the existence of the running processes of the user.

Press “z

What is the purpose of the top command and how can you use it to stop a process?

If you want to remove the color or go back in the previous situation, press the same key.

Color the respective column

To highlight the specific column from the result, you need to use the key ‘b’ in running the top command prompt.

Press ‘b

What is the purpose of the top command and how can you use it to stop a process?

Change the delay time or add interval

Many processes of the same or different users are running at a time. To speed up the system process or to do it more accurately, we need to add time intervals between the processes. In Linux, this could be done by pressing the ‘d’ option that changes the delay time. By default, it is 3, but we can change it by providing the new number. It is also known to be screen refresh interval.

Press “d

Change delay from 3.0 to 4.0

What is the purpose of the top command and how can you use it to stop a process?

The output shows that the delay option is changed from 3 to 4. “d” option deals with specifying the delay between the screen updates. This time is again changed back by using again “d” or the key “s”. The negative number is not allowed to enter for the delay time.

If you want to check the delay time between the screens updating and you have to exit the top command. So you can check it by:

What is the purpose of the top command and how can you use it to stop a process?

Kill the task/process

You can kill the task by finding the PID you want to cease working. To abort the process, you may have to do two things. One is to either press enter tab at the PID prompt, or the other is to type O at the signal prompt. This can be done by pressing the option “k” in the top running command. Make sure you have not exited from that window; otherwise, it will not work.

Press K

PID to signal/kill[default pid = 2057] 2095

What is the purpose of the top command and how can you use it to stop a process?

After pressing the key, the screen will show the line that will want a PID from you so that the system identifies this id and abort it. The output shows that we have provided the recent id 2095 to be ceased.

Search the process

You can filter the process list according to your own choice by providing the criteria like memory usage, CPU process name, etc. For this purpose, you need to press ‘o’ in the running top command prompt.

Press O

When you press the key ‘o’, a line will be shown; this will show the format of the filter.

Add filter #1 (ignoring case) as: [!] FLD? VAL

The field you want to search can write after the line has ended. Suppose we want to filter the result with the help of a command name so that I will write this like.

COMMAND = rcu_ta+

What is the purpose of the top command and how can you use it to stop a process?

After that, hit enter tab. After this, you will see that only the lines having command equals to your searched criteria are shown in the result.

What is the purpose of the top command and how can you use it to stop a process?

Renice a task/process

If you want to change the priority of any process or a task, then use option ‘r’. After entering the key to the prompt, a line will be shown where you need to enter the PID to change the priority.

Press ‘r

PID to renice [default pid = 2057]

What is the purpose of the top command and how can you use it to stop a process?

If you write a positive number, then it will cause the current process to lose priority. Whereas the negative number will cause the kernel to give it more importance.

Show /Hide the process information

1. Using l

This will hide the average load information from the screen that is present at the top of the description. You can see the output from the image.

What is the purpose of the top command and how can you use it to stop a process?

2.Using m

This key will hide the memory information from the description.

What is the purpose of the top command and how can you use it to stop a process?

3. Using t

This will hide the information of the CPU and tasks present in the system.

What is the purpose of the top command and how can you use it to stop a process?

4. Using f

F implies the columns at the top. By default, the top command shows some columns. Whereas there are many columns behind. You can manage the columns by hiding and showing them by your choice. It is done by pressing f in the top command prompt.

What is the purpose of the top command and how can you use it to stop a process?

Operating Batch-mode

To observe the batch mode, you need to exit the top command prompt and then write the command. This is used to send output to other processes or the file.

What is the purpose of the top command and how can you use it to stop a process?

Top command-line

If you want to see the last state/position of the processes when you have closed at the last time, then we can use the ‘c’ option in the command. The last state is reserved. So when you next time opens the top command prompt, it will start from the same state.

What is the purpose of the top command and how can you use it to stop a process?

Top mode security

If you want to secure your top command resultant value mode, you can do this by using the ‘s’ key in the top command.

What is the purpose of the top command and how can you use it to stop a process?

Idle processes are toggled by a specific key

We will use ‘I’ to toggle the idle or sleepy processes.

Press ‘i

What is the purpose of the top command and how can you use it to stop a process?

Sort reversely

To arrange the output in reverse order or to display it in ascending order, you need to use the ‘R’ key in the command.

Press ‘R

What is the purpose of the top command and how can you use it to stop a process?

Display output in different panels

If you want to split the output view, you may use the A key in the top command prompt. Each panel will contain different files and different sets in the display.

Press ‘A

What is the purpose of the top command and how can you use it to stop a process?

Conclusion

This article is collectively done by adding the simplest to critical examples of the Linux Top commands. These commands show the daily usage in the Linux operating system.