Linux free memory: How to show the free memory on a Linux system

Linux memory FAQ: How do I show the free memory on a Linux system?

Solution

You can show free memory on a Linux system with the free command, like this:

free

That command returns results like this:

            total       used       free     shared    buffers     cached
Mem:       8145044    8097552      47492          0      74252    1189464
-/+ buffers/cache:    6833836    1311208
Swap:     12578884    6205424    6373460

If you prefer to see information in MB you can use the -m parameter, like this:

free -m

to get results like this:

            total       used       free     shared    buffers     cached
Mem:          7954       7931         23          0         73       1172
-/+ buffers/cache:       6685       1269
Swap:        12284       6059       6224

Finally, here's the full usage information for the free command:

usage: free [-b|-k|-m|-g] [-l] [-o] [-t] [-s delay] [-c count] [-V]
  -b,-k,-m,-g show output in bytes, KB, MB, or GB
  -l show detailed low and high memory statistics
  -o use old format (no -/+buffers/cache line)
  -t display total for RAM + swap
  -s update every [delay] seconds
  -c update [count] times
  -V display version information and exit

The top utility

If you'd like to see a real-time view of the memory use of applications running on your system you can use the top utility by just typing top at the command line:

top

This starts up an interactive utility you can work with. Keeping with the "memory" theme of this blog post, type a capital letter "M", and top will sort the output by memory used by each running process. After you've seen everything you need, just type "q" to quit the top utility.

Linux ps command and memory

In a related note, this article shows how to sort Linux ps command output by memory use.