Pin Me

Linux Command Line: top

written by: jlwallen•edited by: J. F. Amprimoz•updated: 7/4/2011

For Linux administrators, the "top" command is one of the holy grails. If you have an application that is currently eating up your system resources, top is where you turn to find out what that program is. This entry in the Linux Command Line series will show you how to take advantage of top.

  • slide 1 of 5


    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.

  • slide 2 of 5

    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
    • 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.

  • slide 3 of 5

    Top in action

    Top in action
  • slide 4 of 5

    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.
  • slide 5 of 5

    Final thoughts

    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.