12 TOP Command Examples in Linux
This is the part of our on-going series of commands in Linux. We have covered basic ls command and cat command. In this article, we are trying to explore top command which is one of the most frequently used commands in our daily system administrative jobs. top command displays processor activity of your Linux box and also displays tasks managed by kernel in real-time. It’ll show processor and memory are being used and other information like running processes. This may help you to take correct action. top command found in UNIX-like operating systems.
You might also be interested in following tutorials :
- Htop (Linux Process Monitoring) tool for RHEL, CentOS & Fedora
- Iotop (Monitor Linux Disk I/O) in RHEL, CentOS and Fedora
1. Display of Top Command
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 via field letter, for example press ‘a‘ letter to sort process with PID (Process ID).
Type any key to return to main top window with sorted PID order as shown in below screen. Press ‘q‘ to quit exit the window.
3. Display Specific User Process
Use top command with ‘u‘ option will display specific User process details.
# top -u tecmint
4. Highlight Running Process in Top
Press ‘z‘ option in running top command will display running process in color which may help you to identified running process easily.
5. Shows Absolute Path of Processes
Press ‘c‘ option in running top command, it will display absolute path of running process.
6. Change Delay or Set ‘Screen Refresh Interval’ in Top
By default screen refresh interval is 3.0 seconds, same can be change pressing ‘d‘ option in running top command and change it as desired as shown below.
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 as shown below.
8. Sort by CPU Utilisation
Press (Shift+P) to sort processes as per CPU utilization. See screenshot below.
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
There are number of arguments to know more about top command you may refer man page of top command. Please share it if you find this article useful through our comment box below.










Can someone please help me to gather only the top 20 processes information from the top command into a file after each 60 seconds of interval?
@Victor,
Here is the article, that will list Top 15 Processes by Memory Usage with Top Command.
Excellent Ravi,
Thank you for you information..
Hi Ravi
Point 10 saving top’s output to a file saves it configuration instead.
Please suggest in that,correct it if its wrong.
PFB output.
RCfile for “top with windows” # shameless braggin’
Id:a, Mode_altscr=0, Mode_irixps=0, Delay_time=3.000, Curwin=0
Def fieldscur=AEHIOQTWKNMbcdfgjPlrsuvyzX
winflags=62777, sortindx=15, maxtasks=0
summclr=1, msgsclr=1, headclr=3, taskclr=1
Job fieldscur=ABcefgjlrstuvyzMKNHIWOPQDX
winflags=62777, sortindx=0, maxtasks=0
summclr=6, msgsclr=6, headclr=7, taskclr=6
Mem fieldscur=ANOPQRSTUVbcdefgjlmyzWHIKX
winflags=62777, sortindx=13, maxtasks=0
summclr=5, msgsclr=5, headclr=4, taskclr=5
Usr fieldscur=ABDECGfhijlopqrstuvyzMKNWX
winflags=62777, sortindx=4, maxtasks=0
summclr=3, msgsclr=3, headclr=2, taskclr=3
@Abishek,
Yes its just only saves top configuration, to save the top running output to a file use the following command.
This is very helpful. Is there a guide to definitions of all the top headers? i.e. PR, NI etc.
This was VERY helpful for my OCR Computing Controlled Assesment, thanks!
If server has multiple processor suppose (3) is CPU usage will show 300% in top command or consolidate under 100%, and How can we see individual CPU Usage if server has multiple processors
just hit “1”. It will break out the the various CPUs
Ravi, it’s good collection of examples. Each and every details covered. Want to see more of this kind of work
@Srinivas,
Thanks for finding these example top command useful, more to come stay tuned..
Thank you very much ! Very helpful and useful.
Now I use : top -u myUser
Hello, I was wondering if anyone could help me by evaluating the usefulness of the top command to a technician when using it with ps and kill in order to investigate a system that is misbehaving. Thank you.
@Prince,
I suggest you to read the following articles that shows how to troubleshoot Linux systems when things misbehave….:)
https://www.tecmint.com/audit-network-performance-security-and-troubleshooting-in-linux/
https://www.tecmint.com/linux-system-monitoring-troubleshooting-tools/