output list of processes sorted for RAM USAGE“

ps uax --sort %mem; # sort for current ram usage

vim /scripts/stats_ram_usage.sh; # create that file and fill it with:

#!/bin/bash

# output the top X processes consuming most RAM

free -m;


if [ $# -eq 0 ]
  then
    echo "please give how many processes that consume the most RAM should be displayed"
  else
    ps -eo pmem,pcpu,rss,vsize,args --sort %mem|tail -n $1;
fi

usage:

# output the top 20 RAM consuming processes

/scripts/stats_ram_usage.sh 20

             total       used       free     shared    buffers     cached
Mem:          3959       2760       1199        113         77        783
-/+ buffers/cache:       1899       2060
Swap:         2962          0       2962

 0.4  0.0 18772  56744 /usr/lib/mate-panel/wnck-applet
 0.4  0.0 19108 171032 /usr/bin/mate-settings-daemon
 0.4  0.0 19300 106956 mate-volume-control-applet
 0.4  0.1 19632  56656 /usr/lib/virtualbox/VBoxSVC --auto-shutdown
 0.4  0.0 19964  68092 /usr/lib/mate-panel/clock-applet
 0.5  0.1 21800  49604 marco
 0.5  0.0 24096  75944 nm-applet
 0.6  0.0 24560 100500 caja
 0.6  0.0 25936 103744 mate-screenshot
 0.6  0.0 27272  28872 /usr/bin/tor --defaults-torrc /usr/share/tor/tor-service-defaults-torrc --hush
 0.6  1.5 27836  91904 psensor
 0.6  0.0 28272  78480 pluma
 0.7  0.0 30392 132696 /usr/sbin/ntop -d -L -u ntop -P /var/lib/ntop --access-log-file /var/log/ntop/access.log -i wlan1 -p /etc/ntop/protocol.list -O /var/log/ntop
 1.0  2.5 43744  95708 /usr/bin/X :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch
 1.1  3.7 45320 202108 vlc
 1.4  0.0 56928 120412 mate-panel
 1.4  0.0 57372  89236 python /usr/bin/streamtuner2
 4.8  0.8 197428 698984 icedove
 8.4 10.7 342044 881020 firefox-esr
29.3  6.2 1190356 1368908 /usr/lib/virtualbox/VirtualBox --comment Debian64 --startvm xxxxxxx-xxx-xxxx-xxxx-xxxxxxxxxx --no-startvm-errormsgbox
username@debian:~/temp$
admin