I'd like to start top
with sorting set to resident memory size, instead of the default CPU usage.
I don't see a way to do that from command line arguments or startup file. Obviously I can't echo "Oq" | top
either since I'd prevent top
from using the tty.
Is there a way to do this?
Update: I run top
on Linux (recent Ubuntu and Debian, 3.x kernels), installed e.g. as 'procps 1:3.2.8-11ubun', though I suppose that the column ordering functionality might be pretty cross-platform.
Best Answer
top -M
sorts by resident memory usage.This is the version of top on my system.
If your Linux distribution supports the
-M
flag, you could use it as mentioned here.However, if your
top
doesn't support the-M
flag, you could launch yourtop
command and get into the interactive mode by typing h to check the sort field. (I assume it is the same across various distributions)In my system (rather the
top
version of my system), I could type F or O to select the sorting field and key Q of mytop
version lets me sort on resident memory.If you want to save your configuration you could do something as mentioned by slm here.
Saving configuration
You can use the Shift+W to save your changes so they're the defaults:
The file is stored here,
$HOME/.toprc
, and looks like this:See section 5 of the man page for more details, "5. FILES".