How to Use the top Command in Linux

How to Use the top Command in Linux

Hello Geeky, so today we are focusing on How to Use the top Command in Linux. So please read this tutorial carefully so you may comprehend it in a better helpful way.

Guide: How to Use the top Command in Linux

The top command in Linux gives useful statistics about system resources. We can use it to view CPU and memory usage alongside process information of running services. You can also find zombie processes using top. So, mastering the top command is a must for Linux admins.

The following section provides a simple overview of the top command and shows how to use top in real-world scenarios.

How Does the top Command Work?

By default, top shows a list of running processes alongside standard CPU metrics. You can think of the first part of the output as the dashboard. The bottom section shows the process list and provides a real-time display of all running processes.

The dashboard consists of five lines, each containing some metrics. The first line shows short information about the system, such as the uptime, load average, and the number of users currently logged in. Tasks are shown in the second line. The third one shows CPU load, and the following two lines indicate memory usage.

Note that the commands you specify while running top are case-sensitive. For example, the n and N keys both perform different operations.

1. Display All Running Processes

When used without any arguments, the top command outputs a list of all currently running processes.


You can navigate the output using the Up, Down, PageUp, and PageDown keys on your keyboard. Hit q to get to the shell.

2. Sort Linux Processes by PID

You can sort the process list by their Program ID or PID. Press the N key when running top to sort processes based on PID.

3. Sort Processes by Memory and CPU Usage

The default top output sorts the process list based on the CPU usage. You can sort the list by memory usage using the M key on your keyboard. Enter P to sort by CPU again.

4. Sort Processes by Running Time

If you want to find out for how long processes are running on your machine, press the M and T keys.

5. Display Running Processes for Specific Users

We can view a list of all running processes that belong to a specific user. When inside top, press u and then supply the username and press Enter. You can also use the -u option of top followed by the username to do this.

top -u root

The aforementioned command outputs all processes invoked by root.

6. Highlight Active Processes

If you enter the z key inside top, it will highlight all actively running Linux processes. It makes navigating active processes simpler.


Guide about How to Use the top Command in Linux

In this guide, we told you about the How to Use the top Command in Linux; please read all steps above so that you understand How to Use the top Command in Linux in case if you need any assistance from us, then contact us.

How this tutorial or guide assisting you?

So in this guide, we discuss the How to Use the top Command in Linux, which undoubtedly benefits you.

Final note

I hope you like the guide How to Use the top Command in Linux. In case if you have any queries regards this article/tutorial you may ask us. Also, please share your love by sharing this article with your friends and family.

Trickbugs: Get the latest Trick and Tips
Enable registration in settings - general