Home / Guides / Mac Disk Usage Commands: du, df and find Cheat Sheet
Mac disk usage commands: a du, df and find cheat sheet
Quick answer: du -hd 1 ~ | sort -hr | head -20 lists the 20 biggest folders in your home folder, biggest first. Run it again inside whichever folder is on top to drill down.
Find the biggest folders
du -hd 1 ~ 2>/dev/null | sort -hr | head -20
du -hd 1 ~/Library 2>/dev/null | sort -hr | head -20
du -hd 1 ~/Library/Application\ Support 2>/dev/null | sort -hr | head -20
-h prints sizes people can read, -d 1 goes one level deep, sort -hr puts the biggest first and head -20 keeps the top twenty. On one test Mac the second command put Developer on top at 36 GB, then Application Support at 20 GB and Caches at 9.1 GB.
Find the biggest files
find ~ -type f -size +500M -print 2>/dev/null
find ~ -type f -size +1G -print 2>/dev/null
ls -lhS ~/Downloads | head
The first two list files bigger than 500 MB and 1 GB. The last lists a folder's files with the biggest on top. Old installers and disk images often turn up in Downloads.
Check free space
df -h /System/Volumes/Data
diskutil apfs list | grep -E "Capacity In Use|Capacity Not Allocated"
df counts in GiB, while macOS Settings counts in GB, so the numbers differ by about 7 percent for the same disk. See what purgeable space is for the rest of why tools disagree.
Measure one location
du -sh ~/Library/Caches
du -sh ~/.cache ~/.npm ~/.gradle ~/.cargo 2>/dev/null
sudo du -sh /Library/Caches /private/var/log /private/var/vm 2>/dev/null
sudo du -xhd 1 /System/Volumes/Data 2>/dev/null | sort -hr | head -15
-s prints one total per argument and -x stays on a single volume so nothing is counted twice. sudo is needed for system folders and asks for your password.
Snapshots
tmutil listlocalsnapshots /
diskutil apfs listSnapshots /
Make it faster or easier
- Run
ncdu ~afterbrew install ncdufor an interactive browser inside Terminal. - Protected folders print
Operation not permitted. Give Terminal Full Disk Access in System Settings if you need to read them. - Prefer a picture? A disk visualizer draws the same numbers as a map.
Once you know what is big, see what is inside System Data for how to read the results, and how to clear System Data safely for what to do next.
A map of your Mac's disk, and a safe way to clean it.
Frequently asked questions
What does 2>/dev/null do in these commands?
It hides the error messages. Without it, du prints Operation not permitted for every folder macOS protects, which buries the useful lines.
What is the difference between sort -h and sort -hr?
sort -h sorts human-readable sizes such as 4.5G and 120M from small to large. Adding r reverses it, so the biggest come first.
Do these commands change or delete anything?
No. Every command on this page only reads sizes and names.
Why does du show a different size than Finder?
du reports the space actually used on disk. Finder can show a file's apparent size, which for sparse files such as Docker.raw is much larger.
Related guides
- How to view what is inside System Data on Mac: a Terminal audit: Measure each place System Data hides in with a few read-only commands, with real numbers from one Mac.
- How to see what is taking up space on your Mac: From Storage settings to Terminal to treemap apps: ways to find what fills your Mac and when to use each.
- What is System Data on Mac, and why is it so big?: What the grey bar in Storage settings contains, why it grows and why its size jumps around.