03. Dynamically Viewing Processes top

To see process information in real time, use the top command. top is a text-based program that shows all processes running and updates every few seconds so you can monitor them in real-time.

command line ps aux gif

The view is separated into two halves - the top half is the system summary, while the bottom half is a table of processes sorted by the CPU activity. top is sorted by CPU usage by default.

The system summary

Let's break down just the top half part of top.

$ top
top - 23:07:07 up 13 min, 2 users, load average: 0.02, 0.14, 0.14 Tasks: 160 total, 3 running, 157 sleeping, 0 stopped, 0 zombie %Cpu(s): 31.7 us, 8.9 sy, 0.0 ni, 59.1 id, 0.4 wa, 0.0 hi, 0.0 si, 0.0 st KiB Mem: 501496 total, 495492 used, 6004 free, 2568 buffers KiB Swap: 522236 total, 289316 used, 232920 free. 83052 cached Mem

First row, top:

up - The amount of time since the machine was last booted.
users - Number of users logged in.
load average - Number of processes that are waiting their turn at the CPU in the last 1, 5 and 15 minutes. Any values < 1.0 means machine is not busy.
Number of processes and their various process states.
The task's share of the CPU time since the last screen update.
us is the CPU being used for user processes. Processes outside the kernel itself.
sy is how much is used for system processes (kernal).
ni is how much is used by nice processes.
id is the amount of CPU that is idle.
wa is percentage waiting for I/O.
How much physical RAM is being used.
How much swap space is being used.

Checking system load average

Another way you can check load average without going through top is with the uptime command. You can use this command to quickly check if you have a runaway process that may have hung.

Key Commands

You can access the help screen with the h key or ?. To quit, press q. Here are some other commands you may use:

Kill a process by inputting PID number.
Change a processe's priority. Positive value decrease priority while a negative value increases. Default is 0 to begin with, and ranges are from -20 to 20.
Display update rate (seconds).
Sets display to sort by CPU usage.
Change the display to sort by memory usage.


top, like many other commands, come with several options.

-d delay
Delay between updates - default is 5 seconds.
-p pid
Monitor specific processes.
-n iter
Tell top to display a certain number of updates, and then quit.
Batch mode.

Aching back from coding all day?

Self-Massage Tool

Aching back from coding all day? Try Back Problems

Relieve spasms, tight muscles, trigger points and pressure points with the Body Back Buddy! This trigger point massage is designed to help you self-message any area of your body - especially those that are hard to reach. Keeping your muscles relaxes and out of contraction is importan in helping to reduce pain and prevent muscle injury.

$ Check price
29.9529.95Amazon 4.5 logo(3,443+ reviews)

More Back Problems resources

Take your Linux skills to the next level!

Command Line Kung Fu

Take your Linux skills to the next level! Try Linux & UNIX

Command Line Kung Fu is packed with dozens of tips and practical real-world examples. You won't find theoretical examples in this book. The examples demonstrate how to solve actual problems. The tactics are easy to find, too. Each chapter covers a specific topic and groups related tips and examples together.

$ Check price
14.9914.99Amazon 4.5 logo(27+ reviews)

More Linux & UNIX resources