Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When my computer is slowing down, I usually run ps aux --sort -rss to find out which process consumes too much memory. There may be a lot of processes. How to see only a few ones?

share|improve this question
up vote 1 down vote accepted

You can tell ps to sort its output. But this seems to be a use case for top or htop. Press M to sort processes by memory and P to sort by CPU time.

share|improve this answer
thank you. It's much simpler than ps -eo pid,command,pcpu,pmem --sort -rss | head -N (N is the number of processes I'd like to see. – Maksim Dmitriev Apr 11 '13 at 8:13

ps aux --sort -rss | head would seem to be the best bet. head with no argument will display the first 10 lines of its standard input (which would mean the ps column headers, followed by the first 9 processes as returned by your ps command). To see a different number of processes, call head -n <n> where <n> is the number of lines you want.

share|improve this answer
I tested the command you had given. It printed names of the processes with all their arguments as a string. It would quite suit me if I didn't use head. head made the table unreadable. I used ps -eo pid,command,pcpu,pmem --sort -rss | head -5 (to see 5 processes). – Maksim Dmitriev Apr 10 '13 at 12:20
head prints on its standard output what it reads on its standard input - it's all strings. Show us what you got, and what you want, and perhaps we can get you closer. – D_Bye Apr 10 '13 at 12:27
I want and I got. – Maksim Dmitriev Apr 10 '13 at 12:39
Drop the -e flag on ps. It causes ps to print each process's environment, which is not what you show in the "I want" image. – D_Bye Apr 10 '13 at 12:43
I don't understand you. I print all the processes and decrease the output with head. Is anything wrong here? – Maksim Dmitriev Apr 10 '13 at 14:07

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.