free
Overview
The free command displays the total amount of free and used physical and swap memory in the system, as well as the buffers and caches used by the kernel.
Syntax
free [options]Common Options
| Option | Description |
|---|---|
-b |
Show output in bytes |
-k |
Show output in kilobytes |
-m |
Show output in megabytes |
-g |
Show output in gigabytes |
-h |
Human readable output |
-s N |
Update every N seconds |
-t |
Show total line |
-w |
Wide output |
--si |
Use powers of 1000 not 1024 |
Key Use Cases
- Monitor system memory usage
- Check available memory
- Monitor swap usage
- System performance analysis
- Memory leak detection
Examples with Explanations
Example 1: Human Readable Output
free -hShows memory usage in human readable format
Example 2: Continuous Monitoring
free -s 5Updates memory statistics every 5 seconds
Example 3: Total Memory Usage
free -tShows total memory usage including swap
Understanding Output
Columns explained: - total: Total installed memory - used: Used memory - free: Unused memory - shared: Memory shared by multiple processes - buff/cache: Memory used by buffers and cache - available: Memory available for new applications
Common Usage Patterns
Check memory status:
free -hMonitor memory changes:
free -hs 1Get detailed view:
free -wt
Performance Analysis
- Monitor available memory
- Watch swap usage
- Check buffer/cache usage
- Consider total vs available
- Monitor trends over time