HomeBlogsHow to Use the top Command in Linux

How to Use the top Command in Linux

Hi everyone, in this article we will show you how to use the top command in Linux. The top (table of processes) command shows a real-time view of running processes in Linux and displays tasks managed by the kernel. The command also provides a summary of system information that shows resource usage, including CPU and memory usage. So, without further delay, let’s get started.

The top command in Linux provides useful statistics on system resources. We can use it to view CPU and memory usage along with process information for running services. You can also find zombie processes using 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 to Use the top Command in Linux

1. Show all running processes

  • When used without any arguments, the top command generates a list of all processes that are currently running.
  • top
  • You can navigate through the output using the Up, Down, Page Up and PageDown keys on your 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 when running the top to sort processes based on PID.

3. Sort processes by memory and CPU usage

  • The default top output sorts the process list according to 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 execution time

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

5. Show running processes for specific users

  • We can see a list of all running processes that belong to a specific user. When you are at the top, press u and then provide the username and press Enter. You can also use the -u option at the top followed by the username to do this.
  • root -u upper
  • The aforementioned command spawns all processes invoked by root.

6. Highlight active processes

  • If you enter the z key inside the top, it will highlight all the Linux processes that are actively running. Facilitates navigation through active processes.

Final Words

We hope you like our article about using the top command in Linux. The Linux top command is one of the mainstays of Unix-like operating systems. Its useful display is packed with useful information about the running processes and resource usage of your system. So if you like our article, share it with others.

James Hogan
James Hogan is a senior staff writer at Bollyinside, where he has been covering various topics, including laptops, gaming gear, keyboards, storage, and more. During that period, they evaluated hundreds of laptops and thousands of accessories and built a collection of entirely too many mechanical keyboards for their own use.


Must Read

- Advertisment -