Disk Space Commands
Essential Linux Commands for Filesystem Size Management
1. df Command
The df
command displays filesystem disk space usage across mounted partitions.
## Basic usage
df
## Show size in human-readable format
df -h
## Display specific filesystem information
df /home
2. du Command
The du
command estimates file and directory space consumption.
## Show directory size
du -sh /var/log
## List subdirectory sizes
du -h /var/log/*
## Show top largest directories
du -h /home | sort -rh | head -n 10
Command Comparison
graph TD
A[Disk Space Commands] --> B[df: Filesystem Overview]
A --> C[du: Directory/File Details]
3. Filesystem Commands Comparison
Command |
Purpose |
Key Options |
df |
Filesystem space |
-h (human-readable) |
du |
Directory/file space |
-sh (summary, human) |
fdisk |
Partition management |
-l (list partitions) |
4. Advanced Usage Examples
## Combine commands for detailed analysis
df -h | grep root
du -sh /home/* | sort -rh
5. Monitoring Techniques
- Real-time disk space tracking
- Automated disk space alerts
- Periodic filesystem health checks
At LabEx, we emphasize practical skills in filesystem management and monitoring.