Linux Commands - free (view RAM memory)

The free command is used to view how much memory (RAM) is available. The free command without any options will display the available memory in bytes.

~]# free
              total        used        free      shared  buff/cache   available
Mem:       10054428     5930312      297116      217544     3827000     3592572
Swap:       8388604       45056     8343548

 

Typically, the -h or --human option is used to view the available memory rounded:

  • B = bytes
  • K = kilobytes
  • M = megabytes
  • G = gigabytes
  • T = terabytes
  • P = petabytes
~]# free --human
              total        used        free      shared  buff/cache   available
Mem:           9.6G        5.7G        289M        212M        3.7G        3.4G
Swap:          8.0G         44M        8.0G

 

The --total flag can be used to print the total memory (mem + swap).

~]$ free --human --total
              total        used        free      shared  buff/cache   available
Mem:            15G        5.7G        3.3G        107M        6.5G        9.4G
Swap:          8.0G          0B        8.0G
Total:          23G        5.7G         11G

 

The following options can be used to round the values.

  • -b or --bytes
  • -k or --kilo
  • -m or --mega
  • -g or --giga
  • --tera
  • --peta
~]$ free --giga
              total        used        free      shared  buff/cache   available
Mem:              9           5           0           0           3           3
Swap:             7           0           7

 

The -s or --seconds option can be used to rediplay the output every x seconds. Optionally, the --count option can be used to limit the number of times the output will be redisplayed, such as 10 times in this example.

free --seconds 1 --count 10

 

If swap memory free is low, refer to Linux Fundamentals - Analyzing swap memory.




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee

Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.





Please enter a0e2c in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |