Check Disk Usage on Mac Using Terminal
Understanding disk usage is the first step before cleaning up storage. Using terminal commands gives you precise visibility into what is consuming space on your Mac.
Use df to view overall disk usage
The df command shows overall disk usage across mounted filesystems.
df -hThis will display:
- Total disk size
- Used space
- Available space
- Mounted volumes
Use this to quickly confirm if your root (/) partition is running out of space.
Use du to identify large directories
The du command helps you drill down into directories and identify large folders.
du -sh /*To go deeper into your home directory:
du -sh ~/*This helps pinpoint directories like Downloads, Library, or Applications consuming the most storage.
Identify What is Taking System Storage
macOS often shows “System Data” as a large chunk of storage. This includes logs, caches, backups, and hidden files.
Analyze ~/Library and /System folders
Check user-level system files:
du -sh ~/Library/*For system-level usage (requires sudo):
sudo du -sh /System/*Focus on:
- Caches
- Logs
- Application support files
These are common contributors to system storage. You can also list all files sorted by size
Find large files using find command
To locate large files (e.g., >500MB) you can use find command:
find / -type f -size +500M 2>/dev/nullYou can limit search to your home directory:
find ~ -type f -size +200MThis helps identify forgotten large files like videos, backups, or installers.
Clear Cache and Temporary Files
Cache and temporary files are safe to remove in most cases and can free up significant space.
Remove user cache safely
User cache is stored under your home directory:
rm -rf ~/Library/Caches/*This will clear application cache files. Apps may rebuild cache when needed.
Clean system cache directories
System-level cache requires elevated privileges:
sudo rm -rf /Library/Caches/*Be cautious and avoid deleting unknown critical directories. Stick to cache paths only.
Cleaning cache regularly helps reduce “System Data” size and improves performance.
Remove Logs and Temporary System Data
Log files and temporary system data can grow over time and occupy significant disk space. Cleaning them periodically helps reclaim storage.
Delete logs from ~/Library/Logs
User-level logs can be safely removed:
rm -rf ~/Library/Logs/*These logs are usually generated by applications and are recreated automatically when needed.
Clean /var/log safely
System logs are stored under /var/log. Use caution while deleting:
sudo rm -rf /var/log/*Alternatively, you can inspect before deleting:
sudo du -sh /var/log/*Only remove large or unnecessary logs to avoid losing important debugging data.
Clean Xcode and Developer Files
If you use Xcode, it can consume several gigabytes of storage through derived data and simulator files.
Remove DerivedData and archives
Clear Xcode build cache:
rm -rf ~/Library/Developer/Xcode/DerivedData/*Remove old archives:
rm -rf ~/Library/Developer/Xcode/Archives/*Delete unused simulators
List available simulators:
xcrun simctl listDelete unavailable simulators:
xcrun simctl delete unavailableThis can free up a large amount of disk space.
Manage Local Snapshots and Hidden Storage
macOS creates local snapshots for Time Machine backups, which may consume hidden storage.
List Time Machine local snapshots
tmutil listlocalsnapshots /Delete unnecessary snapshots
sudo tmutil deletelocalsnapshots <snapshot-date>Replace <snapshot-date> with the actual snapshot identifier from the previous command.
Move or Archive Large Files
Instead of deleting important data, consider moving or compressing it.
Use external storage or cloud
Move large files to an external drive:
mv ~/Downloads/largefile.zip /Volumes/ExternalDrive/Or upload to cloud storage like iCloud or other providers.
Compress files using tar or zip
Compress files to save space using tar command:
tar -czvf archive.tar.gz /path/to/folderOr using zip command:
zip -r archive.zip /path/to/folderBest Practices to Prevent Storage Issues
Maintaining disk health regularly helps avoid sudden storage issues.
Automate cleanup using cron
Create a cron job to clean cache periodically using crontab command:
crontab -eExample entry (runs daily at midnight):
0 0 * * * rm -rf ~/Library/Caches/*Monitor disk usage regularly
Check disk usage periodically:
df -h
du -sh ~/*This helps you identify storage growth early and take action before it becomes critical.
Frequently Asked Questions
1. How do I check disk usage on Mac using terminal?
You can use commands like df -h to check overall disk usage and du -sh * to identify large directories consuming space.2. What is taking up system storage on Mac?
System storage may include cache files, logs, Xcode data, local snapshots, and temporary system files.3. Is it safe to delete cache files on Mac?
Yes, most cache files can be safely deleted as they are temporary and will be recreated when needed.4. How to remove logs from Mac to free space?
Logs can be removed from /var/log and ~/Library/Logs using terminal commands, but caution is advised to avoid deleting important system logs.Summary
Managing system storage on macOS becomes much easier when you use terminal-based tools. Instead of relying only on the graphical interface, commands like df, du, and find help you quickly identify disk usage and locate large files.
In this guide, you learned how to:
- Analyze disk usage using terminal commands
- Identify what contributes to “System Data” storage
- Clear cache, logs, and temporary files safely
- Remove Xcode and developer-related storage
- Manage Time Machine local snapshots
- Compress or move large files efficiently
- Automate cleanup and monitor disk usage regularly
By following these steps, you can reclaim significant storage space and maintain better system performance on your Mac.
Official Documentation
For deeper understanding and safe usage of commands, refer to official documentation:
- How to free up storage space on your Mac (Apple Support)
- df command reference (macOS)
- du command reference (macOS)
- find command reference (macOS)
- Xcode documentation (Apple Developer)
These resources provide detailed explanations and help ensure safe execution of commands on your system.






![How to undo rm in Linux? [100% Working]](/how-to-undo-rm-in-linux-100-working/undo-rm-linux_hu_acdf3239d801bb86.webp)
![How to modify smbd process limit in Linux? [SOLVED]](/linux-smbd-process-limit/linux-smbd-process-limit_hu_baba4c446fc38c7f.webp)
![Working with ulimit in Linux [Beginners Guide]](/ulimit-linux/ulimit_linux_hu_24e298a8c9cbde06.webp)

