top command in Linux with examples.

Top (Table of Process) command acts like task manager in Windows. It displays information about Number of User currently logged in, load average, task status, and usage of  CPU, Memory & SWAP, process running in real-time of the system. top command is very important tool for monitoring current load and various other activities on the server. By default, top command refreshes screen every 3 seconds. You can refresh manually pressing ENTER or SPACE key. In this post, we will understand some of the examples and usage tips of Top command which is very useful for effective monitoring of resources of the system. Note: All the options with top command are case sensitive.
1. top command with no options.
Below top command displays screen in interactive mode. In the output, Upper half shows usage of resources and Lower half displays the running processes. You can any time press “q” to quit from the running screen.
# top
Let’s understand output of top command in details.
– On top line marked in screen print shows current time, no of days since system is up and running, number of user currently active and load average of system refer as 1 minute, 5 minutes and 15 minutes.
– Second line  shows total  number of running, sleeping tasks.
– Third line displays CPU usage.
– Fourth & Fifth line classified as total memory, free, used & buffer and SWAP or Virtual Memory classified as total, free, used & cached.
2. “h” or “?” for help
In running top command you can press “h” or “?” for help menu which shows list of help options available and “ESC” key for return in top command.
3. “k” options to kill running process.
Press “k” key in top command to kill a specific PID.

Also read:-

4. Sort with process

“M” Sort by Memory usage
“P” Sort by Processor usage
“N” Sort by Process ID
“T” Sort by Processor running time

5. Display absolute path of running process

Press key “c” to display the full path of running process while running top command. If you again press “c” to go back to default top running screen.

6. List process own by specific user
To list a process for a user, press “u” while top is running and type username in the area, if you leave it blank will shows process for all users.

7. Type below command from console to list process own by a user.
# top -u tomcat

8. Save your output of settings.
You can save the setting or changes made for later use, press key “W”. This will save it’s configuration in .toprc file in home directory of user.
9. Running process in color.
Press key “z” in running top command to display running process in color to identified and visualize easily.

10. Sort by CPU usage
Press “Shift+P” in running top command to sort as per CPU usage.

Conclusion: In this tutorial, we have seen Top Command in Linux with Examples. Big thanks for reading all the way to the end. Type man top from command prompt to know more about top command. Please share it with Your Friends & Help Someone… and also Like Our Facebook Page. Let me hear your thoughts in the comments below!

Leave a Comment