Display the top ten running processes - sorted by memory usage

ps axo %mem,pid,euser,cmd | sort -nr | head -n 10
Sample Output
11.5  1957 lainme   firefox http://twitter.com/keyi_bu/status/256446157193093120/photo/1
 3.4  1813 lainme   /usr/bin/gnome-shell
 3.3  1867 lainme   /usr/bin/python2 /usr/bin/hotot-gtk3
 2.6  5183 lainme   conky
 1.5  1645 root     /usr/bin/Xorg :0 -br -verbose -auth /var/run/gdm/auth-for-gdm-3aSYDI/database -nolisten tcp vt8
 1.0  1854 lainme   pidgin
 1.0 18439 lainme   fcitx
 0.9  1998 lainme   /usr/lib/firefox/plugin-container /usr/lib/mozilla/plugins/libflashplayer.so -greomni /usr/lib/firefox/omni.ja 1957 plugin
 0.4  1821 lainme   nm-applet
 0.4  1785 lainme   /usr/lib/gnome-settings-daemon/gnome-settings-daemon

0
By: lainme
2012-10-12 03:27:26

2 Alternatives + Submit Alt

  • ps returns all running processes which are then sorted by the 4th field in numerical order and the top 10 are sent to STDOUT. Show Sample Output


    99
    ps aux | sort -nk +4 | tail
    root · 2009-01-23 17:12:33 9

  • 4
    ps aux --sort -rss | head
    unixmonkey42657 · 2012-11-14 17:47:50 0

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: