LINUX UNIX

[Solved -4 Answers ] UNIX – How to display `top` results sorted by memory usage in real time

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

  • Use quick tip using top command in linux/unix
Bash Code
   top
  • 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.

Use quick tip using top command in linux/unix

Bash Code
$ top
  • and then hit Shift+m (i.e. write a capital M).

From man top

Bash Code
SORTING of task window
  For compatibility, this top supports most of the former top sort keys.
  Since this is primarily a service to former top users, these commands do
  not appear on any help screen.
    command   sorted-field                  supported
      A         start time (non-display)      No
      M         %MEM                          Yes
      N         PID                           Yes
      P         %CPU                          Yes
      T         TIME+                         Yes
  • Or alternatively: 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

If top is already running, press o . Above the data, a prompt will appear:

Bash Code
primary key [xxxxx]:
  • Where xxxxx is the current sorting key. Type the name of the column by which you want to sort. If a column name contains “%” or “#”, omit the character.
  • For example, %CPU, just type “cpu”.

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 you want to short by memory usage you usually use

Bash Code
                    top -o %MEM
  • which sorts by the column %MEM. But you can use VIRT, RES or SHR too. On a Macintosh you would probably use mem or vsize.
READ  Use Linux And Miss CCleaner? Check Out These Alternatives

About the author

Wikitechy Editor

Wikitechy Editor

Wikitechy Founder, Author, International Speaker, and Job Consultant. My role as the CEO of Wikitechy, I help businesses build their next generation digital platforms and help with their product innovation and growth strategy. I'm a frequent speaker at tech conferences and events.

X