When i run top
on my Macbook (BSD?) i almost always want to sort by CPU%
it dosent seem to be the default, so I wind up typing 'o' (to sort) and type in 'cpu' and hit enter all the time!
is there a way to make sort-by-CPU% the default or something?
%CPU is the default sort column on every system I've ever used. But if it's not, you can press Shift-P to sort by %CPU. Note that it's not listed in interactive help, only the man page.
M %MEM
N PID
P %CPU
T TIME+
top -o +%CPU
As John Kugelman said, usually %CPU is a default sort column. Anyway, reading man top(1) seems a good idea.
Looking at the top manpage, you can use option -o %CPU
, although that should already be the default. You could create an alias in your .bashrc (alias top='top -o %CPU'
) to make this permanent.
-o :Override-sort-field as: -o fieldname
Specifies the name of the field on which tasks will be sorted, independent of what is reflected in the configuration file. You can prepend a '+' or '-' to the field name to
also override the sort direction. A leading '+' will force sorting high to low, whereas a '-' will ensure a low to high ordering.
This option exists primarily to support automated/scripted batch mode operation.
Another way is to establish the sorting you prefer in top
and then press W
to save the configuration. Next time you start top
it is going to load the config.
Press h
in top
to see keyboard shortcuts.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With