The `top`
command is a Linux utility that is used to display real-time information about running processes on a system. It provides a summary of the current state of the system, including the CPU, memory, and swap usage, as well as a list of running processes and their resource utilization.
Using the top command is simple: just enter `top`
at the command prompt and press Enter. The top command will display a list of running processes, along with their process IDs, CPU and memory usage, and other information. By default, the list is sorted by CPU usage, with the most CPU-intensive processes at the top.
- Sysstat – Linux System Performance Monitoring Tool
- Glances – A Real-Time Linux System Monitoring Tool
Using this article, I am trying to explain understanding and interpreting the Output of the Linux `top` Command
Understanding and Interpreting the Ouptut of the Linux `top`
Command
The top command is a Linux utility that is used to display real-time information about running processes on a system. When you run the top command, it displays a list of running processes, along with their process IDs, CPU and memory usage, and other information. Here’s how to read and interpret the output of the top command:
Result Row #1
The first row (Row 1) typically displaying the overall system summary. This summary includes the current time, uptime of the system (how long the system has been running since the last boot), the total number of user sessions, and the load average over the last 1, 5, and 15 minutes. The load average represents the average system load during these intervals, giving an indication of how busy or idle the system resources are. This row serves as a quick snapshot of the system’s health and performance.
Result Row #2
The second row of the top command output in Linux displays information about processes or tasks being managed by the system. It shows the total number of tasks and breaks them down into different states: running, sleeping, stopped, and zombie. Running tasks are currently executing, sleeping tasks are waiting for an event or time, stopped tasks have been halted (usually by a signal), and zombie tasks have completed execution but still have an entry in the process table. This row provides a quick overview of the system’s process activity, helping users understand the current workload and system behavior.
Zombie process or defunct process is a process that has completed execution but still has an entry in the process table. This entry is still needed to allow the parent process to read its child’s exit status.
Result Row #3
The third row of the Linux top command output details CPU usage, breaking it down into various categories: user processes, system processes, nice tasks, idle time, wait time, hardware interrupts (HI), software interrupts (SI), and steal time (ST). This information helps in identifying how the CPU resources are being allocated—whether they’re consumed by user applications, system processes, or are idly waiting, providing insights into the system’s performance and potential bottlenecks.
Steal time is the time that a virtual CPU waits for a real CPU while the hypervisor is servicing another virtual processor.
Definition from access.redhat.com
Result Row #4
The fourth row of the Linux top command output presents memory usage statistics, including total physical memory (RAM), used memory, free memory, and buffers/cache memory. This row offers a snapshot of memory allocation and availability, helping users understand how much memory is being actively used by processes versus how much is available for new processes. It also shows memory used for buffering and caching, which can improve performance by reducing disk access times.
Result Row #5
The fifth row in the Linux top command output focuses on swap space usage, showing total swap, used swap, and free swap space. Swap space is a form of virtual memory that allows the system to use disk space as an extension of RAM. This row is crucial for understanding how much of the disk space is being used to supplement physical memory and whether the system is heavily relying on swapping, which can impact performance.
Result Row #6 ( Running Processes )
In sixth row in top command it shows all the running processes on servers with additional details. These process listings include details such as PID, user, priority, CPU and memory usage, and command name, providing real-time insights into which processes are consuming the most resources.
Short Results Based on Specific Criteria
To customize how results are sorted, use the key combination SHIFT + F. This allows you to prioritize the display of processes based on specific criteria. Simply select your preferred field from the options presented and press ENTER to apply the new sorting order. This feature enhances the way you analyze and monitor process metrics.
A
: PID = Process Idb
: PPID = Parent Process Pidd
: UID= User Ide
: USER = User Namef
: GROUP = Group Nameg
: TTY= Controlling Ttyh
: PR = Priorityi
: NI = Nice valuej
: P = Last used cpu (SMP)k
: %CPU = CPU usagel
: TIME = CPU Timen
: %MEM = Memory usage (RES)o
: VIRT = Virtual Image (kb)p
: SWAP = Swapped size (kb)q
: RES= Resident size (kb)r
: CODE = Code size (kb)s
: DATA = Data+Stack size (kbt
: SHR= Shared Mem size (kb)w
: S = Process Statusx
: COMMAND= Command name/line
Wrap Up
In conclusion, a top command is a powerful tool that is used to display real-time information about running processes on a Linux system. When you run the top command, it displays a list of running processes, along with their process IDs, CPU and memory usage, and other information. By understanding and interpreting the output of the top command, you can get a better understanding of the current state of the system and the resources being used by various processes. With this knowledge, you can use the top command to monitor and manage processes on your Linux system more effectively.
16 Comments
nicely explain.
Excellent way of explaining. Really useful
Clear and crisp. Thank you Rahul
Row #2 and Row #3 are same, whereas Row #2 should be Tasks and Row #3 should be CPU(s)
Hi
Please check the typo mistake.(in row3 last line ni–>st).this one helped me much.
Thank you,
siva kumar reddy.
Thanks Siva, Image has been updated.
Neat work and well explained. Thank you for this KM.
Very informative , thanks for sharing it.
Awesome explanation, however %ni has been repeated twice which should be %st : steal time in the CPU Usage Section. Please correct it.
Thanks
Abhimanyu Singh
Very nice explanation but some more description of fields
You are missing a key point or am i?
In result row #1 you have the load averge of cpu time in 1min, 5min and 15min.
Results are:
3.48 @ 1min.
4.98 @ 5min.
4.11 @ 15min.
but what those there number mean.? it cannot be a readout of the CPU load averge over 1min, you CPU would be idle most of the time if the averge load is 3.48, on my linux machine this number is less than 1.
So wtf is it?!?!?.
Well it’s not like your Windows friendly view, it’s linux and thank god.
It’s hard to explain and maybe someone else can do it better but here goes.
Lets say your system is running with a 4 core CPU, on a Windows PC you would see the 4 cores and the average load each sec.
You can’t simply move one thing to another core, just like you can’t walk through two doors at the same time.
However my wife would arguing this.
We can’t do two things at the same time, but if we have two doors, why not send one thing through one door and another through the next and so on.
Btw a CPU with hyperthreading is not a core…!
So lets say it’s a 4 core CPU, and we have the same average load of 3.48 the first minute, then 4.98 every 5 minute and 4.11 every 15minute.
We can translate this to 3 of the cores are at 100% load, and one if at 48%.
However this is not true, as we cannot see each core, but the totalt amount so we can only guess.
This should tell you that there is still a good 52% left on one core, and we don’t need to raise an alarm depending on the average load every 5 or 15min.
Now every 5min we have a load over 4. It’s 4.98 and i lost you again.
If we have 4 core where every core can max at 1 why do we have above 4 on a 4 core system?
Well this counter is so much more, it’s current load or a givin load over a time, it’s the amount the system would like to utilize over a givin periode of time.
WTF.! stop plz.
Yeah i know, if only it was Windows and we could all die in a puddel of licens.
Install htop, it would give you a more “user friendly” view.
On debian you should just apt-get install htop
redhat users should add repoforge anyway.
Now that we know our system is overloaded, how can we fix it?
By using top to see what is hooking all the CPU time.
Hope you can update you’re guide to include what these numbers mean as they are not the amount of CPU load in %
You can find this number on a linux machine with this command cat /proc/cpuinfo | grep ‘model name’ | wc -l
Hey,
This article seems to basic informative with variable explanations within top command, why are you arguing with load values. Also please specify why your are specifying overload with 4 core! Does the article mentioned in such a way!!!
Last but not least, Please do manner in your replies….:)
Nice explanation. people can understand very easily even he/she does not know.
Very nice explanation but still you can explain in detail about swap size,cached size,Buffer size etc..
u given a clear explanation, so please update the other commands also like this.
Very nice and clearly explained…… thanks for sharing this…..