The Linux top command has roots in the VMS operating system’s topcpu. As it is seen in today’s Linux, top was created for BSD in 1984 by William Lefebvre. Since its creation, top has been re-released many times for many operating systems (and many licenses). But throughout, the purpose of top has remained the same - to report current running tasks in real-time. Because top runs real time, as processes change the listing changes.
What top reports
When top is run there are two portions of the window: The top portion is the summary section. This is where you’ll find an overall system summary. This summary consists of total system memory, total running tasks, total zombied tasks, total users, load average, etc. The bottom portion is the process section. This shows all current running processes. Both sections are updated in real time.
A typical process entry contains the following important information:
- task PID (process identification number)
- user associated with the processes
- virtual memory used
- % CPU used
- % memory used
- uptime of command
Some of the information isn’t as helpful to the average administrator. The above listing will give you everything you need to know about a process.
Top in action
Top memory confusion
There is always some confusion about memory usage with top. If you look at the sample image above you will see that top is only reporting 7996k of free memory. But if you were on that system you would know that there is more memory available than that. Instead of believing what you see you have to understand what is actually being reported. Here’s how it looks:
- The first section (in our sample showing 772764k total)
- The second section (in our sample showing 764768k used)
- The third section (in our sample showing 7996k free)
Here’s how it really breaks down:
- The first line shows active memory which is any memory being used by any application.
- The second line shows inactive memory which is any memory that is not being used but has yet to be marked as available for applications to use. This means the system is holding this memory for use by applications that will need it. In other words the memory that is available for applications, in our example, is 764768.
Top is an incredibly useful tool and should be a permanent part of your Linux administrators' toolkit. Get to know top and allow it to help you make your administrative tasks easier.
This post is part of the series: Linux Command Line
If you ever plan on doing any administration on a Linux machine, you would be well served to get to know the command line interface. In this Bright Hub series you will be introduced to various concepts surrounding one of the most powerful admin tools around.
- Linux Command Line: Introduction
- Linux Command Line: ls
- Linux Command Line: cd
- Linux Command Line: mkdir
- Linux Command Line: df
- Linux Command Line: ln
- Linux Command Line: top
- Linux Command Line: mount/umount
- Linux Command Line: Cron/Crontab
- Linux Command Line: chmod
- Linux Command Line: wget
- Linux Command Line: cat
- Linux Command Line: grep
- Linux Command Line: dd
- Linux Command Line: sudo
- Linux Command Line: startx
- Linux Command Line: adduser
- Linux Command Line: at
- Linux Command Line: aterm
- Linux Command Line: nano
- Linux Command Line: hostname