Display the top ten running processes - sorted by memory usage

top -b -o +%MEM |head -17
Display the top processes sorted by memory usage. This is mostly useful because it's easy to remember and can give me a quick 'top' view of a group of servers when used over pssh. (Though I'd recommend |head -10 to minimize the output).
Sample Output
top - 14:54:54 up 3 days,  4:39,  5 users,  load average: 0.10, 0.17, 0.15
Tasks: 316 total,   1 running, 315 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.9 us,  0.3 sy,  0.1 ni, 98.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  8175368 total,  1388840 free,  2213492 used,  4573036 buff/cache
KiB Swap:  8257532 total,  8257532 free,        0 used.  5714152 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
30976 dakini    20   0 2649524 681272 131368 S   6.2  8.3  57:55.27 firefox
 2144 dakini    20   0 2056856 243632  69048 S   0.0  3.0  22:13.71 gnome-shell
 1574 root      20   0  978376 214076  17856 S   0.0  2.6   0:25.62 packagekitd
 1904 dakini    20   0  388248 195396  22928 S   0.0  2.4  28:35.51 Xorg
 1465 gdm       20   0 1614860 116032  66160 S   0.0  1.4   0:08.12 gnome-shell
 3583 dakini    20   0  219288  90724   2692 S   0.0  1.1   0:49.73 tmux
 2364 dakini    20   0  853944  87344  21156 S   0.0  1.1   0:02.48 gnome-software
 2433 dakini    20   0 1207172  70356  30632 S   0.0  0.9   0:00.27 evolution-calen
  575 root      20   0  134428  67536  66848 S   0.0  0.8   0:09.54 systemd-journal
 2532 dakini    20   0 1357140  66860  27932 S   0.0  0.8   0:00.24 evolution-calen

0
By: dak1n1
2016-03-16 22:14:34

4 Alternatives + Submit Alt

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: