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

With ps command I can find out how much memory each program uses:

ps -u mertnuhoglu -o pcpu,rss,pid,command

Is it possible to find out the sums of each type of resource usage as well, easily?

share|improve this question
Note that quantifying memory usage is tricky, because some memory is shared between processes. The sum of the figures you get this way will be an overestimate. RSS is only a rough estimate of how much memory an application uses anyway (it doesn't take into account swapped-out memory or file buffers). – Gilles Oct 1 '11 at 22:05
up vote 7 down vote accepted

You could sum the usage columns with awk:

ps --no-headers -u $USER -o pcpu,rss | awk '{cpu += $1; rss += $2} END {print cpu, rss}'

You might also be interested in the free command for memory usage:

$ free
             total       used       free     shared    buffers     cached
Mem:       2055480    1806596     248884          0      14016     346276
-/+ buffers/cache:    1446304     609176
Swap:      2097148     132980    1964168

The output is in kilobytes (use free -m for megabytes). In particular, the used, +/- buffers/cache entry is something like the total physical memory used (by everyone).

share|improve this answer

You can try:

$ ps -eo vsz,comm= | awk 'NR>1{u[$2]+=$1}END{for(i in u) print u[i]"="i}' 
share|improve this answer
Do not only paste command. please also mansion/explain how this command use to solve this question. – Tejas Dec 18 '14 at 9:54

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.