How to investigate a misbehaving system using the Top command?

I need to ask professionals about the usefulness of the top command and How do you use top with ps and kill to investigate a system that is misbehaving? I would also if possible to get answer with key terminology to be able to evaluate the usefulness of the top command

hi,

A top command is overview tool of usage of %cpu % mem ,pid & nice value(ni - which is used to prioritize the process the lower nicer value the bigger the priority)that being used.

And it displays wide variety of O/P, it gives which process (PID) & user is consuming more cpu, it will help to keep healthy.

ex : top -u username , will give particular user info.

And inside command u can also kill a process by just clicking “q” , but remember the q here gives actual kill -9 signal, which will kill the process without actually halting it down.

and you can always set the cpu limit for a particular process & you can always write a simple shell script to kill the process which is taking more cpu if needed.

and ps command is process.

Ps -ef - will list all process running in system and you can grep it always the process you want to check.

thanks,
Root

1 Like

Hi!

Top command is used to display processor activity of a Linux box and also displays tasks managed by kernel in real-time. It’ll show processor and memory are being used and other information like running processes. @root1250 has explained almost all about it.

About ps command I can give you some tip/trick to display on what processes are causing memory higher usage and also the cpu higher usage.

For memory:

# ps aux --sort -rss (This prints the ps output with the largest RSS size at the top of the output)
# ps aux --sort rss (To reverse this output and show the largest RSS value at the bottom of the ps command output)

For CPU:

# ps aux --sort=-pcpu (This prints the ps output with the largest CPU size at the top of the output)

And finally, you can kill any proccesses you want with the kill -9 command and the number of the PID or proccess for example:

# kill -9 65327

Hope it helps you!