Beginner · 5 min · practise every command in the built-in terminal

free — Display Memory Usage

free -h          # Human readable (MB/GB)
free -m          # In megabytes
free -s 2        # Update every 2 seconds

Output:

              total    used    free  shared  buff/cache  available
Mem:           7.7G    3.2G    1.5G   450M       3.0G       3.8G
Swap:          2.0G    100M    1.9G

Understanding the columns

ColumnMeaning
totalTotal RAM
usedUsed by processes
freeCompletely unused
sharedUsed by tmpfs
buff/cacheUsed by OS caching
availableAvailable for new processes

⚠️ available is what matters, not free. Linux uses free RAM for disk cache (buff/cache) which gets freed when apps need it.

Other memory commands

cat /proc/meminfo         # Detailed memory info
vmstat 1 5               # Virtual memory stats (5 iterations)

Swap space

Swap is disk space used as overflow RAM. It's much slower.

swapon --show            # Show swap usage

Practice tasks

  1. Show memory usage in a human-readable format
  2. Show memory usage in megabytes
  3. View detailed memory info from the kernel

Commands in this lesson

Disk & Memory