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?

  • 1
    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). Oct 1, 2011 at 22:05

2 Answers 2


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 --mega for megabytes or free -m for mebibytes). In particular, the used, +/- buffers/cache entry is something like the total physical memory used (by everyone).


You can try:

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .