How can I display the
top results in my terminal in real time so that the list is sorted by memory usage?
top command in Linux/Unix:
- press shift+m after running the
- or you can interactively choose which column to sort on
- press Shift+f to enter the interactive menu
- press the up or down arrow until the
%MEMchoice is highlighted
- press s to select
- press enter to save your selection
- press q to exit the interactive menu
Or specify the sort order on the command line
# on OS-X top -o MEM # other distros top -o %MEM
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
SHR too. On a Macintosh I would probably use
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.
If you're using the
top that comes with Ubuntu (
top -v =
procps-ng version 3.3.10), then you can use these interactive keyboard shortcuts to change the sorting. Note that these are all capital letters, so either use
By default, they will be sorted in DESC order. Use
R to toggle ASC/DESC.
To set the sorting from the command line option, use
top -o %MEM. You can specify any column.