Top is a Linux process and resource usage monitoring utility. It allows users to view real-time information about the running processes and threads managed by the system’s kernel. Because of its interactivity, top enables users to perform tasks, such as filtering for specific processes, filter processes by users, PID, and kill processes.

This guide will walk you through the basics of using the ps command to locate specific information about the system.

Basic Top Utility Usage

To launch the top utility, use the top command in the terminal. Using this command will spawn an interactive session showing system resource usage and running processes:

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/word-image-446.png" data-lazy- height="464" src="data:image/svg xml,” width=”722″>

The upper part shows the resource usage. This output is similar to that of uptime and the free command in Linux.

To turn these values off, press “m” to hide the memory usage information and “l” to hide the uptime information.

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/word-image-447.png" data-lazy- height="269" src="data:image/svg xml,” width=”955″>

To scroll through the running processes, use the up and down arrow key. To quit, press “Q”.

Top Output

The lower part of top command contains information about running processes. Let us focus on this.

The output uses a column-based organization, with an identifier on each:

  • PID: This column shows the unique ID of each process.
  • PR: This column shows the priority of the task.
  • NI: This column shows the nice value of the process. A positive value indicates low priority, while a negative value indicates high priority.
  • VIRT: This column represents the total virtual memory used by the process.
  • RES: This column shows the total actual memory used by the process.
  • SHR: This column shows the total amount of shared memory used by the process.
  • S: This column shows the process state in a single letter.
  • %CPU: This column shows percentage CPU usage per process.
  • %MEM: This column shows percentage Memory usage.
  • TIME : This column shows CPU time used by the process calculated to hundredths of a second.
  • COMMAND: This column shows the process name.

How to Make Top Filter Processes by Memory Usage

You can also filter processes by memory usage in top. To do this, press SHIFT m as shown:

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/word-image-448.png" data-lazy- height="482" src="data:image/svg xml,” width=”902″>

Top will filter the processes by memory usage in descending order. Doing this can help identify the process using the most memory, giving you a chance to take action.

To filter by actual memory usage, use the command:

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/word-image-449.png" data-lazy- height="328" src="data:image/svg xml,” width=”890″>

Similarly, the command will filter the memory usage in descending order.

You can also interactively choose the filter parameter. To do this, press SHIFT F and select MEM as:

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/word-image-450.png" data-lazy- height="469" src="data:image/svg xml,” width=”786″>

How to Filter Process by User

To show processes from a specific user, use the command:

For example, to show processes from the ubuntu user; enter the command:

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/word-image-451.png" data-lazy- height="472" src="data:image/svg xml,” width=”1010″>

How to Show the Parent and Child Processes

To show the parent and child processes while top is running, press V. This will give you an output similar to the one shown below:

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/word-image-452.png" data-lazy- height="789" src="data:image/svg xml,” width=”1162″>

How to Kill All Processes

To kill a process in top, press k and enter the PID of the process.

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/word-image-453.png" data-lazy- height="367" src="data:image/svg xml,” width=”917″>

Press enter to execute the kill command. This will terminate the process with the specified PID.

Conclusion

Top is a handy utility that makes it possible to understand and manage the Linux System processes. Besides what we have discussed in this tutorial, top has tons of other functionalities.

To understand how you can customize and use top to its full potential, consider the manuals.

About the author

<img alt="" data-del="avatar" data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/john-150×150.png60f5e5ee8881e.jpg" height="112" src="data:image/svg xml,” width=”112″>

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list