free Linux Command
Displays the amount of free and used system memory (RAM and swap).
What does free do?
Displays the amount of free and used system memory (RAM and swap).
Syntax
free [options]Practical example
free -hQuestions about free
How do I check memory usage?
Use `free -h` to see memory usage in human-readable format. This shows total, used, free, and available RAM and swap.
What does free -h show?
It displays total, used, free, shared, buff/cache, and available memory for both physical RAM and swap space.
What is the difference between free and available?
Free is completely unused memory. Available is memory that can be freed up (includes buffers/cache). Available is the more useful metric.
How do I see memory in megabytes?
Use `free -m` to display memory usage in megabytes. Use `-g` for gigabytes.
What is buff/cache in free output?
Buff/cache shows memory used by the kernel buffers and page cache. This memory can be freed when applications need it.
How do I see swap usage?
Use `free -h` and look at the 'Swap:' line. If used swap is high, the system may be running low on RAM.
How do I clear the cache?
Use `sudo sync && echo 3 | sudo tee /proc/sys/vm/drop_caches` to clear caches. This is safe but usually not necessary.
How do I see memory usage of a specific process?
Use `ps aux --sort=-%mem | head -10` to see the top 10 processes by memory usage.
Related System Information
lsusbLists all USB devices connected to the system.
vmstatReports virtual memory statistics including CPU, memory, and I/O.
lspciLists all PCI devices connected to the system (graphics cards, network adapters).
dmesgPrints the kernel ring buffer messages (boot-time and hardware diagnostics).
lsblkLists information about all available block devices (disks and partitions).
lsmodLists all currently loaded kernel modules.