Memory usage per user in Linux?
Solution 1:
You could try using smem (see ELC2009: Visualizing memory usage with smem for more information). In particular, sudo smem -u
should give you the information you want.
Solution 2:
Ignoring shared memory issues, here's a quick script that gives you RSS and VMEM for all logged in users, sorted by vmem, and organized into cute columns:
(echo "user rss(KiB) vmem(KiB)";
for user in $(users | tr ' ' '\n' | sort -u); do
echo $user $(ps -U $user --no-headers -o rss,vsz \
| awk '{rss+=$1; vmem+=$2} END{print rss" "vmem}')
done | sort -k3
) | column -t
Solution 3:
To get sum of RSS I think the following works. This would be to get the sum of RSS for the users kbrandt and root.
ps -U kbrandt,root --no-headers -o rss | (tr '\n' +; echo 0) | bc