free
Overview
The free
command displays the amount of free and used memory in the system. It shows information about both physical and swap memory.
Syntax
free [options]
Common Options
Option | Description |
---|---|
-b |
Bytes |
-k |
Kilobytes |
-m |
Megabytes |
-g |
Gigabytes |
-h |
Human readable |
-w |
Wide output |
-s N |
Repeat every N sec |
-c N |
Repeat N times |
-t |
Show total |
-l |
Show low/high |
Output Fields
Field | Description |
---|---|
total | Total memory |
used | Used memory |
free | Unused memory |
shared | Shared memory |
buff/cache | Buffer/cache |
available | Available memory |
Key Use Cases
- Memory monitoring
- System resources
- Performance analysis
- Capacity planning
- Troubleshooting
Examples with Explanations
Example 1: Basic Usage
free
Show memory info
Example 2: Human Readable
free -h
Easy to read format
Example 3: Continuous
free -s 5
Update every 5 seconds
Common Usage Patterns
Quick check:
free -h
Monitor changes:
free -s 1 -c 10
Total memory:
free -t
Memory Types
- Physical memory
- Swap memory
- Buffer memory
- Cache memory
- Shared memory
Additional Resources
Best Practices
- Regular checks
- Use human readable
- Monitor trends
- Check available
- Document usage
Performance Analysis
- Memory usage
- Swap usage
- Buffer usage
- Cache usage
- Available memory
Troubleshooting
- Low memory
- High swap
- Cache usage
- Memory leaks
- System performance
Common Issues
- Memory pressure
- Swap thrashing
- Cache problems
- Memory fragmentation
- Resource exhaustion