When a Linux system is slow or behaving unexpectedly, memory is one of the first things to check. This guide covers four methods to check RAM usage in Linux, from a quick summary to per-program breakdowns.
The free command gives a fast memory summary. The most useful flags:
bashfree -h # human-readable (KiB, MiB, GiB)free -m # megabytesfree -g # gigabytesfree -s 5 # refresh every 5 seconds
Output includes two rows: Mem: for physical memory and Swap: for swap space.
The three columns that matter:
buff/cache value is normal behavior, not a sign of a memory problem.The used value is calculated as total - free - buffers - cache. The shared column is a legacy field kept for backward compatibility — ignore it.
Note on free -g: it rounds DOWN to whole gigabytes. If less than 1 GiB is free, the column shows 0. Use free -m or free -h for accurate output.
The top command displays running processes in real time. The header shows total, used, and free physical and swap memory. The %MEM column shows each process’s share of available RAM:
bashtop
For raw memory data without a live display, read /proc/meminfo directly:
bashcat /proc/meminfo
This file does not exist on disk. The kernel exposes it at runtime, and it is the data source behind free, top, ps, and other system tools. MemFree shows completely unused memory; MemAvailable shows the realistic usable estimate — the same concept as the available column in free output. The file can be parsed directly in shell scripts.
ps_mem is a Python script that groups memory usage by program name – useful for identifying the heaviest RAM consumer:
bashsudo ps_mem
Each line shows Private + Shared = RAM used with the program name. Private is memory used only by that process. Shared is memory shared with other processes (libraries, shared buffers). Programs are listed in ascending order with a total at the bottom.
On Ubuntu 23.04 and later, install with pipx to avoid conflicts with the system Python environment:
bashpipx install ps_mem
On older systems:
bashsudo pip3 install ps_mem
For a quick check, run free -h and look at the available column. For per-process investigation, ps_mem shows which program is using the most RAM. Leave a comment below if you run into any issues.