Top command to show the %cpu in descending order

bash, linux, shell, ubuntu

Solution

Run top as a process (I'm using Ubuntu 14.04)

top

Once in top...

P <- Sort by CPU usage

M <- Sort by MEM usage

z <- Add cool visual colors

x <- Highlight column you are currently sorting by

Problem

I would like to have the cpu percentage in decending order. When I give the command : ``` top -bn 1 | grep "^ " | awk '{ printf("%-8s %-8s \n", $2, $9); }' | head -8 ``` It shows processes which are not the top most using CPU.

Original source