Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

How can I display the top results in my terminal in real time so that the list is sorted by memory usage?

share|improve this question
On Linux, > and < move the sort column right and left. Since the %MEM column is just right of the %CPU column, which is also the default sort column, it takes only one keystroke to switch between the two. I know, your question has the macintosh tag, that's why I'm writing this answer as a comment. – Walter Tross Sep 19 at 18:37

5 Answers 5

Use quick tip using top command in linux/unix


hit Shift + f, then choose the display to order by memory usage by hitting key n then press Enter. You will see active process ordered by memory usage.

Or you can just press M after running the top command.

On OS X 10.10 the command top -o MEM seems to work.


share|improve this answer
Does not work for me – jan Mar 5 at 11:09
shift+m worked for me on linux – highonprogramming Aug 23 at 12:31

The command line option -o (o standing for "Override-sort-field") also works on my Xubuntu machine and according to the Mac man page of top it should work on a Macintosh too. If I want to short by memory usage I usually use

top -o %MEM

which sorts by the column %MEM. But I can use VIRT, RES or SHR too. On a Macintosh I would probably use mem or vsize.

I don't know why or how but this is pretty much different between Unix systems and even between Linux distributions. For example -o isn't even available on my Raspberry running Wheezy. It may be worth give it a try though.

share|improve this answer
The answer could user more clarity: %MEM is given as an answer to the eager reader; while it doesn't work everywhere (by far). – May 6 at 15:00
For Macbook 2014 this is saying: top -o %MEM invalid argument -o: %MEM – advocate Jun 1 at 17:43
I'm sorry to hear that. – ytg Jun 1 at 20:03

It seems like the -o flag will take the actual column name. So if the top command shows only "mem" then the command should be "top -o mem".

For the ubuntu machine I am testing with, the column is called "%MEM". On the OSX Yosemite I tried, it is "mem".

share|improve this answer

The original question seems to have been for a Mac, but for anyone else stumbling across this answer, on Red Hat Linux (and many others), 'top -m' starts top with results sorted by memory usage.

share|improve this answer

For Ubuntu 14.04 starting with

htop -s=MEM

did the trick for me.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.