How do I find duplicate files taking up space on my Mac?
Locate and remove byte-for-byte duplicate files from the macOS Terminal: rank folders by size, list duplicates by checksum, delete them in one batch, and verify the reclaimed space.
What this covers
Duplicate downloads, copied photos, and synced folders quietly pile up until your Mac's disk fills. This guide walks you from finding where the space went, through identifying true duplicates by checksum, to deleting them safely from the Terminal.
Symptom
Find out which folders are eating the most space
Before hunting for duplicates, see where the space actually goes. Ranking your home folder's top-level directories by size shows you which area (Downloads, Documents, Photos…) is worth investigating. When the command finishes, the biggest folders are listed at the top — start your duplicate search there.
du measures folder sizes; sorted through sort -rh and cut with head, it shows the top space consumers.
$ du -xsh ~/* 2>/dev/null | sort -rh | head -15Drill into a suspicious folder
Once you've picked the folder most likely full of duplicates (Downloads is a usual suspect), rank its subfolders by size. This narrows the search so the checksum pass runs faster and you focus on directories that actually hold weight. You should see a sorted list with the heaviest subfolders last.
Rank every folder by disk usage, biggest last, in human-readable units.
$ du -sh */ | sort -hList the actual duplicates by checksum
Files can have different names but identical contents. A checksum comparison finds every byte-for-byte copy, so you know exactly which files are safe to remove. First cd into the folder you identified, then run the checksum listing. The output is one path per duplicated file group — those are your reclaimable copies.
List files whose contents are byte-for-byte identical, even with different names.
$ cd ~/Downloads && find . -type f -not -name ".DS_Store" -exec md5 -r {} + | sort | awk '{c[$1]++; f[$1]=$2} END {for (h in c) if (c[h]>1) print f[h]}'Delete the duplicate copies in one batch
With the duplicate list in hand, use find -exec to remove the copies in one pass instead of deleting them one by one. Be precise: match only the exact filenames you confirmed as duplicates — a broad pattern will delete files you wanted to keep. When done, the paths from the checksum list should no longer exist.
find -exec turns every search result into an argument of another command, replacing fragile shell loops and xargs plumbing for tasks like deleting all .DS_Store files in a tree.
$ find . -name "*.tmp" -exec rm {} +
find . -name "*.DS_Store" -type f -exec rm -v {} \;Confirm the space is reclaimed
Re-run a size check over your home folder to confirm the cleanup worked. You should no longer see the duplicate copies in the results, and the folder you cleaned should have shrunk compared to your earlier du ranking.
List the biggest files in your home folder that are eating disk space.
$ find ~ -type f -size +500M 2>/dev/null -exec ls -lh {} \;How to confirm it worked
Re-run a large-file listing over your home folder: the duplicate copies should be gone and the cleaned folder should be measurably smaller than in your initial du ranking.
Sources
- du — disk usage (macOS man page)Evidence: Documents du -s (summary per argument), -h (human sizes) and -x (stay on one filesystem).
- shasum – Calculate SHA checksumsEvidence: Checksum tools (md5/shasum) produce identical hashes for identical content — the basis of duplicate detection.
- find – Walk a file hierarchyEvidence: find -type f -exec runs the checksum tool over every file in the tree in batches.
Last verified: 2026-09-21
Related guides
A terminal-first walkthrough to find what is holding your external disk open on macOS and eject it safely, from quitting apps to forcing an unmount.
A diagnose-fix-verify walkthrough for a full macOS disk: measure real free space, map APFS volumes, clear local Time Machine snapshots, and confirm the space came back.
Find out whether your Mac's disk is healthy: check SMART status, rule out a full disk, verify the filesystem, and repair errors from the terminal.