As a Linux administrator,You might be curious about how much memory your running processes are using.In this article we’ll show you some commands that can sort out top processes by memory usage on your Linux system.
Here is a easiest way to display process memory usage, using the ‘ps’ command:
ps ax -o rss,command | sort -nr | head -n 10
If you are running a multi-user system, you can add the process user data to be display:
ps ax -o rss,user,command | sort -nr | head -n 10
To get a constantly updating display, use the ‘watch’ command and specify how often you would like it to update, in this case every 10 seconds:
watch -n 10 'ps ax -o rss,user,command | sort -nr | head -n 10'
You can also Use the following command to find out top processed sorted by memory usage, in megabytes (MB) :
ps axo rss,comm,pid \ | awk '{ proc_list[$2]++; proc_list[$2 "," 1] += $1; } \ END { for (proc in proc_list) { printf("%d\t%s\n", \ proc_list[proc "," 1],proc); }}' | sort -n | tail -n 10 | sort -rn \ | awk '{$1/=1024;printf "%.0fMB\t",$1}{print $2}'
That’s all.