16 September 2026 · One command a day
How do I check memory usage on a Linux server?
The free command shows how much memory your server has, how much is in use, and how much is still available to programs. You reach for it when a site feels slow, when an app has been killed without warning, or when you want to know whether the server has room for one more service. It takes a second to run and needs no root.
The command
free -m
free reads the kernel's memory figures from /proc/meminfo and lays them out as a table. The -m flag prints every number in mebibytes, so 8 GB of RAM appears as roughly 7937 rather than a long string of bytes. Swap -m for -h to get units such as 7.8Gi, or -g for whole gibibytes, though -g rounds down and hides small values. Add -s 5 to refresh every five seconds and watch the figures move.
What you will see
user@host:~$ free -m
total used free shared buff/cache available
Mem: 7937 2412 611 118 5162 5525
Swap: 2047 0 2047
Read the Mem line from the right. The available column is the one that matters. It is the kernel's estimate of how much memory new programs could take without pushing anything to swap. Here that is 5525 MiB, so the server is comfortable. The free column is memory doing nothing at all, and it is usually small. The buff/cache column is memory the kernel is using to hold recently read files so the next read is quick. It hands that memory back the moment a program asks for it. The used column is what programs have actually claimed. The Swap line shows the same picture for disk-backed swap space. Zero used is what you want.
When to use it
- An app restarted on its own and the log says nothing. Run
free -mand checkavailable. If it is close to zero, the kernel's out-of-memory killer probably stopped the process. - You are about to add a database, a second Node app or a Docker container and want to know whether there is room.
- Pages feel sluggish and the Swap line shows heavy use. Memory that has spilled to disk is far slower than RAM, and the fix is usually to trim what is running or move to a bigger plan.
Watch out for
The common mistake is to look at the free column, see a few hundred megabytes on a server with several gigabytes, and conclude the machine is almost out of memory. It is not. Linux deliberately fills spare RAM with file cache because unused memory is wasted memory. That cache is counted under buff/cache and is given back on demand. A low free figure next to a healthy available figure is a server working as designed. Only a low available figure means trouble.
Questions people ask
Why does used plus free not add up to total?
Recent versions of free, including the one on Ubuntu 24.04, calculate used as total minus available, so the columns overlap with buff/cache. Trust available rather than doing the arithmetic yourself.
Which process is using the memory?
free only gives totals. Run ps aux --sort=-%mem | head to list the heaviest processes, or if your apps run under PM2, pm2 list shows memory per app.
On a single VPS with 32 GB of RAM this one command tells you whether 45 websites and 13 apps still have headroom, and you can only ask it on a server you control. You can get the same VPS with 20% off at https://asksteves.co.uk/vps. Affiliate link.
Everything on this blog runs on one Hostinger KVM 8. This link takes 20% off the same box.
Affiliate link.