How to Use the top Command in Linux – Guide

The top command in Linux provides useful statistics about system resources. We can use it to see CPU and memory usage along with process information for running services. You can also find zombie processes using the top. Therefore, mastering the top command is a must for Linux administrators. The following section provides a simple overview of the top command and shows how to use top in real world scenarios.

How does the superior command work?

By default, the top shows a list of running processes along with the default CPU metrics. You can think of the first part of the output as the dashboard. The lower section shows the list of processes and provides a real-time view 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 uptime, load average, and the number of users currently connected. Tasks are shown on the second line. The third shows CPU load and the following two lines indicate memory usage. Note that the commands you specify when running top are case sensitive. For example, the n and N keys perform different operations.

1. View all running processes

When used without any arguments, the top command displays a list of all currently running processes. main You can browse the output using the Up, Down, PageUp and PageDown keys on the keyboard. Press q to get to the shell.

2. Sort Linux processes by PID

You can sort the list of processes by their program ID or PID. Press the N key while running the top to sort processes based on PID.

3. Sort processes by memory and CPU usage

Standard top output sorts the list of processes based on CPU usage. You can sort the list by memory usage using the M key on your keyboard. Type P to sort by CPU again.

4. Sort processes by runtime

If you want to know how long processes have been running on your machine, press the M and T keys.

5. View running processes for specific users

We can see a list of all running processes that belong to a specific user. Once inside the top, press u, provide the username and press Enter. You can also use the top -u option followed by the username to do this. -u root superior The command mentioned above displays all processes invoked by root.

6. Highlight active processes

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

Final note

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

How to Use the top Command in Linux  2022  - 61How to Use the top Command in Linux  2022  - 63How to Use the top Command in Linux  2022  - 99How to Use the top Command in Linux  2022  - 54