Linux top Command with Examples

In this article, we are attempting to explore top command which is perhaps the most frequently utilized commands in our day by day system administrative positions. top command shows processor movement of your Linux box and also displays tasks managed by kernel in real-time. It’ll show processor and memory are being utilized and other information like running processes. This may assist you with making a right action. top command found in UNIX-like operating systems.

Linux top Command with Examples

Linux top Command with Examples:

1. Display of Top Command:

top – display Linux processes : In this example, it will show information like tasks, memory, cpu and swap. Press ‘q‘ to quit window.

# top

2. Sorting with -O (Uppercase Letter ‘O’):

Press (Shift+O) to Sort field through field letter, for instance press ‘a‘ letter to sort process with PID (Process ID).

Type any key to get back to main top window with sorted PID request as shown in below screen. Press ‘q‘ to quit exit the window.

Linux top Command with Examples

Sorting Process ID’s

3. Display Specific User Process:

Utilize top command with ‘u’ option will show explicit User process details.

# top -u itsmarttricks

4. Highlight Running Process in Top

Press ‘z‘ option in running top command will show running process in color which may help you to identified running process without any problem.

Top Process with Colorful

Top Process with Colorful

5. Shows Absolute Path of Processes:

Press ‘c‘ option in running top command, it will display absolute path of running process.

Top with Specific Process Path

Top with Specific Process Path

6. Change Delay or Set ‘Screen Refresh Interval’ in Top:

By default screen revive span is 3.0 seconds, same can be change pressing ‘d‘ option in running top command and change it as desired as shown below.

Top – Kill Process ID

Top – Kill Process ID

7. Kill running process with argument ‘k’

You can kill a process after finding PID of process by pressing ‘k‘ option in running top command without exiting from top window.

8. Sort by CPU Utilisation

Press (Shift+P) to sort processes as per CPU utilization.

9. Renice a Process

You can use ‘r‘ option to change the priority of the process also called Renice.

10. Save Top Command Results

To save the running top command results output to a file /root/.toprc use the following command.

# top -n 1 -b > top-output.txt

11. Getting Top Command Help

Press ‘h‘ option to obtain the top command help.

12. Exit Top Command After Specific repetition

Top output keep refreshing until you press ‘q‘. With below command top command will automatically exit after 10 number of repetition.

# top -n 10

Also Read – Learn Basic Linux System Commands For Linux Foundation Certified IT Associate (LFCA) Certification

That’s all, In this article, we have explained the Linux w command with Examples. I hope you enjoy this article. If you like this article, then just share it and then do subscribe to email alerts for Linux, Windows, macOS, Android, Internet, Firewall and Security, CCTV tutorials. If you have any questions or doubts about this article, please comment.

Share this: