Professional Documents
Culture Documents
applications are using more memory or processing power than they should be.
The top command is very easy to use but you should know the things in details. The output of to is :
top output:
“22:09:08″ is the current time; “up 14 min” shows how long the system has been up for; “1 user” how
many users are logged in; “load average: 0.21, 0.23, 0.30″ the load average of the system (1minute, 5
minutes, 15 minutes).
Load average is an extensive topic and to understand its inner workings can be daunting. The simplest
of definitions states that load average is the cpu utilization over a period of time. A load average of 1
means your cpu is being fully utilized and processes are not having to wait to use a CPU. A load
average above 1 indicates that processes need to wait and your system will be less responsive. If your
load average is consistently above 3 and your system is running slow you may want to upgrade to more
CPU’s or a faster CPU.
The second line in top:
Shows CPU utilization details. “9.5%us” user processes are using 9.5%; “31.2%sy” system processes
are using 31.2%; “27.0%id” percentage of available cpu; “7.6%wa” time CPU is waiting for IO.
When first analyzing the Cpu(s) line in top look at the %id to see how much cpu is available. If %id is
low then focus on %us, %sy, and %wa to determine what is using the CPU.
Describes the memory usage. These numbers can be misleading. “255592k total” is total memory in the
system; “167568K used” is the part of the RAM that currently contains information; “88024k free” is
the part of RAM that contains no information; “25068K buffers and 85724k cached” is the buffered
and cached data for IO.
So what is the actual amount of free RAM available for programs to use ?
Top will display the process using the most CPU usage in descending order. Lets describe each column
that represents a process.
S - State of the task. Values are S (sleeping), D (uninterruptible sleep), R (running), Z (zombies), or T
(stopped or traced)
Now that we are able to understand the output from TOP lets learn how to change the way the output is
displayed.
Just press the following key while running top and the output will be sorted in real time.
z - Color display
k - Kill a process
q - quit
If we want to kill the process with PID 3161, then press “k” and a prompt will ask you for the PID
number, and enter 3161.
Command Line Parameters with TOP
You can control what top displays by issuing parameters when you run top.
$ top -p 3166
$ top -d 5