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.

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

Aching back from coding all day?

Inversion Therapy Table

Aching back from coding all day? Try Back Problems

Stretch out your back and relieve your back muscles with inversion therapy. This device counteracts the forces of gravity on the body by decompressing and elongating the spine. By using this product just ten minutes a day, you can be well on your way to improved circulation and posture while relieving muscle aches, back pain and stress.

$$ Check price
119.98119.98Amazon 4.5 logo(1,700+ reviews)

More Back Problems resources