Commands tagged memory usage (20)

  • This command will add up RAM usage of all processes whose name contains "java" and output the sum of percentages in HRF. Also, unlike the original #15430, it wont fail on processes with a usage of >9.9%. Pleases note that this command wont work reliably in use cases where a significant portion of processes involved are using less than 0.1% of RAM, because they will be counted as "0", even though a great number of them could add up to significant amounts. Show Sample Output

    ps -eo pmem,comm | grep java | awk '{sum+=$1} END {print sum " % of RAM"}'
    bugmenot · 2016-02-10 09:00:56 0
  • Finding high memory usage report in human readable format. Show Sample Output

    ps -eo size,pid,user,command --sort -size |awk '{hr[1024**2]="GB";hr[1024]="MB";for (x=1024**3; x>=1024; x/=1024){if ($1>=x){printf ("%-6.2f %s ", $1/x, hr[x]);break}}}{printf ("%-6s %-10s ", $2, $3)}{for (x=4;x<=NF;x++){printf ("%s ",$x)} print ("\n")}'
    rockon · 2012-11-27 04:29:08 7
  • It displays the top 10 processes sorted by memory usage Show Sample Output

    ps aux | sort -rk 4,4 | head -n 10
    x3mboy · 2019-09-26 16:37:33 2
  • I've wanted this for a long time, finally just sat down and came up with it. This shows you the sorted output of ps in a pretty format perfect for cron or startup scripts. You can sort by changing the k -vsz to k -pmem for example to sort by memory instead. If you want a function, here's one from my aa_top_ps(){ local T N=${1:-10};T=${2:-vsz}; ps wwo pid,user,group,vsize:8,size:8,sz:6,rss:6,pmem:7,pcpu:7,time:7,wchan,sched=,stat,flags,comm,args k -${T} -A|sed -u "/^ *PID/d;${N}q"; } Show Sample Output

    command ps wwo pid,user,group,vsize:8,size:8,sz:6,rss:6,pmem:7,pcpu:7,time:7,wchan,sched=,stat,flags,comm,args k -vsz -A|sed -u '/^ *PID/d;10q'
    AskApache · 2010-05-18 18:41:38 1
  • smem is very clever, it keeps in mind shared memory in its calculations!!! Show Sample Output

    smem --pie name -s pss
    nutria · 2013-02-26 19:18:31 1
  • Top 10 Memory Processes (reduced output to applications and %usage only) Show Sample Output

    ps aux | sort -rk 4,4 | head -n 10 | awk '{print $4,$11}'
    n0a110w · 2019-10-20 22:52:55 0
  • Bash has a built-in time command which provides less functionality than the real time command. Thus we reference /usr/bin/time directly. Since the command isn't very easy to remember you could alias it to something like "cputime" or even just "time". Show Sample Output

    /usr/bin/time -f "\ntime\t%E\nCPU\t%P\nRAM\t%Mk" <command>
    Negate · 2018-10-27 03:11:51 0

  • 0
    pmap $(pgrep [ProcessName] -n) | gawk '/total/ { a=strtonum($2); b=int(a/1024); printf b};'
    lv4tech · 2010-04-28 08:16:28 0

  • 0
    sudo ps aux --sort:rss | awk '{print $2"\t"$11": "$6/1024" MB"}' | column -t | less
    threv · 2011-12-08 17:23:18 0

  • 0
    TOTAL_RAM=`free | head -n 2 | tail -n 1 | awk '{ print $2 }'`; PROC_RSS=`ps axo rss,comm | grep [h]ttpd | awk '{ TOTAL += $1 } END { print TOTAL }'`; PROC_PCT=`echo "scale=4; ( $PROC_RSS/$TOTAL_RAM ) * 100" | bc`; echo "RAM Used by HTTP: $PROC_PCT%"
    0disse0 · 2012-02-03 16:10:36 0
  • Add up the amount of memory your processes are using and display the total. Replace marcanuy with your desired username. Show Sample Output

    ps -u marcanuy -o pid,rss,command | awk '{print $0}{sum+=$2} END {print "Total", sum/1024, "MB"}'
    marcanuy · 2013-11-20 01:21:59 0
  • This command will show the sum total of memory used in gigabytes by a program that spawns multiple instances of itself. Replace chrome with whatever program's memory usage you are investigating. This command is rather useless on software that only spawns a single instance of itself. Show Sample Output

    ps -eo pmem,comm | grep chrome | cut -d " " -f 2 | paste -sd+ | bc
    Darkstar · 2014-01-03 15:33:16 0
  • Displays memory usage for individual instances of an application that spawns multiple instances of itself. This command also works on single process applications. Show Sample Output

    ps -eo pmem,comm | grep application-name
    Darkstar · 2014-02-23 13:21:29 0
  • Monitoring system in one line : DISK : disk space MEM: memory ( mem , swap, Total) CPU : all information about cpu activity LOAD : load average Show Sample Output

    echo "DISK:";df -Pl | grep -v "Filesystem" | awk '{print $5,$6}' ; echo "MEM:" ; free -mto | awk '{ print $1,$2,$3,$4 }'; echo "CPU:"; top -b -d1 -n1 | grep Cpu | awk '{print $2,$3,$4,$5,$6,$7,$8,$9}';echo "LOAD:"; cat /proc/loadavg
    injez · 2014-09-29 12:43:52 0

  • 0
    ps -eo pmem,comm | grep chrome | cut -d " " -f 2 | paste -sd+ | bc
    peter1337 · 2016-01-24 20:45:04 3
  • This is a alternate command I like to use instead of TOP or HTOP to see what are the processes which are taking up the most memory on a system. It shows the username, process ID, CPU usage, Memory usage, thread ID, Number of threads associated with parent process, Resident Set Size, Virtual Memory Size, start time of the process, and command arguments. Then it's sorted by memory and showing the top 10 with head. This of course can be changed to suit you needs. I have a small system which is why Firefox is taking so much resources. Show Sample Output

    watch -n .8 'ps -eaLo uname,pid,pcpu,pmem,lwp,nlwp,rss,vsz,start_time,args --sort -pmem| head -10'
    ubercoo · 2016-05-11 01:05:53 0

  • 0
    cat /proc/meminfo | awk -v"RS=~" '{print "Total:", $2/1024000, "GiB","|","In Use:",100-$5/$2*100"%"}'
    Moshem · 2017-02-20 12:20:01 0
  • The sample output is from an Android Device Show Sample Output

    grep -e AnonHugePages /proc/*/smaps | awk '{ if($2>4) print $0} ' | awk -F "/" '{system("cat /proc/" $3 "/cmdline");printf("\n");print $0; printf("\n");}'
    praton · 2020-01-14 07:50:44 0
  • This command shows a high level overview of system memory and usage refreshed in seconds. Change -n 10 to you desired refresh interval. Show Sample Output

    watch -n 10 free -m
    Darkstar · 2014-01-04 10:10:15 0

  • -1
    CMD=chrome ; ps h -o pmem -C $CMD | awk '{sum+=$1} END {print sum}'
    pdxdoughnut · 2014-01-08 23:05:09 0

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Check These Out

Leap year calculation

Get AWS temporary credentials ready to export based on a MFA virtual appliance
You might want to secure your AWS operations requiring to use a MFA token. But then to use API or tools, you need to pass credentials generated with a MFA token. This commands asks you for the MFA code and retrieves these credentials using AWS Cli. To print the exports, you can use: `awk '{ print "export AWS_ACCESS_KEY_ID=\"" $1 "\"\n" "export AWS_SECRET_ACCESS_KEY=\"" $2 "\"\n" "export AWS_SESSION_TOKEN=\"" $3 "\"" }'` You must adapt the command line to include: * $MFA_IDis ARN of the virtual MFA or serial number of the physical one * TTL for the credentials

find out which directory uses most inodes - list total sum of directoryname existing on filesystem

grep tab (\t)
works in bash

Install a new kernel in Manjaro linux
00 is the number of the linux kernel e.g. linux39

Download 10 random wallpapers from

awk change field separator
GNU Awk 3.1.4

Press ctrl+r in a bash shell and type a few letters of a previous command
In the sample output, I pressed ctrl+r and typed the letters las. I can't imagine how much typing this has saved me.

Exclude multiple columns using AWK
Print all columns except the 1st and 3rd.

awk date convert
Convert readable date/time with `date` command

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: