Sub topic 7
Finding Large Files and Folders in Terminal
This chapter assumes you can open Terminal, know that ~ means your home folder, and have read the earlier chapters on the Storage settings pane. Terminal shows what the Storage pane summarizes, and it can search a specific folder.
Three commands, three questions
| Command | Question it answers |
|---|---|
| `df` | How full is the volume? |
| `du` | Which folders use the most space? |
| `find` | Which individual files are very large? |
Work in that order: volume, then folders, then files.
Step 1: Check the volume with df
df -h /System/Volumes/Datadf reports disk free space. The -h flag prints sizes in human-readable units such as G and T. On modern macOS, your files live on the Data volume, so that is the path to check. Running df -h / shows the read-only system volume, which is not the one filling up.
The Avail column can differ from the free space in Storage settings. Storage settings counts purgeable space as available. df does not.
Step 2: Find large folders with du
du -h -d 1 ~ 2>/dev/null | sort -hr | head -n 10This pipeline has four parts:
du -h -d 1 ~prints the size of your home folder and of each folder directly inside it.-d 1limits the depth to one level.2>/dev/nulldiscards error messages, such as permission denials for protected folders.sort -hrsorts by human-readable size, largest first.head -n 10keeps the first ten lines.
The first line is ~ itself, which is the total. The lines below it show where the space goes. Often Library, Movies, or Downloads is at the top.
To look inside a large folder, repeat the command with that folder as the target:
du -h -d 1 ~/Library 2>/dev/null | sort -hr | head -n 10Each repeat narrows the search by one level.
Step 3: Find large files with find
find ~ -type f -size +1G -exec ls -lh {} + 2>/dev/null| Part | Meaning |
|---|---|
| `~` | Where to search |
| `-type f` | Match regular files only, not folders |
| `-size +1G` | Match files larger than 1 GB |
| `-exec ls -lh {} +` | Run `ls -lh` on the matches to show their sizes |
Lower the threshold, for example -size +200M, if the 1 GB search returns nothing. Common results are virtual machine disks, old iOS device backups, video projects, and downloaded disk images.
Reading the results
Some common pitfalls:
- Sizes that do not match Finder.
dumeasures disk blocks used. Finder may report a different figure for some files, especially sparse files and cloud-synced files whose content is not downloaded locally. - Missing results. Without Full Disk Access, Terminal cannot read some protected folders. Because
2>/dev/nullhides those errors, the totals may be incomplete. Remove2>/dev/nullonce to see what was skipped. - Slow runs. Scanning a whole home folder with many small files can take a minute or more. Wait for the prompt to return.
- Limited scope.
find ~searches only your home folder. Space used outside it, such as in/Libraryor/Applications, will not appear.
Exercise
You run du -h -d 1 ~ 2>/dev/null | sort -hr | head -n 10. The top line shows the total for your home folder, and the next line shows Library at 48G. What is your next command, and why?
Show answer
Run du -h -d 1 ~/Library 2>/dev/null | sort -hr | head -n 10. It repeats the same search one level deeper to show which subfolders of Library use the 48 GB. Narrowing step by step finds the cause without scanning everything at once.
Exercise
find ~ -type f -size +1G -exec ls -lh {} + 2>/dev/null prints nothing. Name two possible reasons.
Show answer
No file in your home folder is larger than 1 GB, so try a lower threshold such as -size +200M. Alternatively, the large files may be in a folder Terminal cannot read without Full Disk Access, and 2>/dev/null hid the errors.