Skip to content

Instantly share code, notes, and snippets.

@aleixripoll
Last active February 6, 2017 14:47
Show Gist options
  • Save aleixripoll/5273884e051c26626a0450fd45da5526 to your computer and use it in GitHub Desktop.
Save aleixripoll/5273884e051c26626a0450fd45da5526 to your computer and use it in GitHub Desktop.
Linux mem usage one-liners

Processes ordered by mem usage in MB:

ps -u $USER -wo rss=,comm= --sort -rss | while read -r rss comm ; do echo $((rss/1024))"MB" $comm; done

Mem used by a process regex in KB:

ps -e -www -o pid,ppid,start_time,pmem,rsz,cmd | grep "<command>" | sort -n -k3 | awk '{print $5"KB RAM |",$6,$7,$8,$9,$10,$11; SUM+=$5} END  {print "Total RAM: "SUM" KB"}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment