rmlint: How to Find and Remove Duplicate Files on Linux
rmlint scans for duplicates and other clutter, then hands you a script to read before anything is deleted. Here is how to install it, run it, keep the right copy, and avoid the mistakes that cost data.
Quick Answer
rmlint is a command-line tool that finds duplicate files, duplicate folders, empty files and folders, and broken symlinks. Run rmlint ~/Pictures to scan: it changes nothing and writes a script called rmlint.sh. Read the script, test it with ./rmlint.sh -n, then run ./rmlint.sh to delete the duplicates it lists.
Every command and output block below was run on rmlint 2.9.0, the version Ubuntu 24.04 ships, and checked against the current manual on rmlint.readthedocs.io. Newer releases add options but keep this workflow. Run rmlint --version to see what you have.
Install rmlint
# Debian, Ubuntu, Linux Mint
sudo apt install rmlint
sudo apt install rmlint-gui # optional: the Shredder GUI
# Fedora
sudo dnf install rmlint
# macOS with Homebrew (command line only, no GUI)
brew install rmlint
# Check the version
rmlint --versionPackage availability has shifted over time: Arch users now get rmlint from the AUR, and some distributions carry older builds. If your package manager cannot find it, the project's GitHub page (github.com/sahib/rmlint) has build instructions using scons. There is no native Windows build; on Windows, install it inside WSL.
Your First rmlint Scan
Point rmlint at one or more directories. It recurses into subfolders by default and skips hidden files unless you add --hidden.
$ rmlint Pictures
# Bad symlink(s):
rm '/home/sam/Pictures/broken-link'
# Empty dir(s):
rmdir '/home/sam/Pictures/empty'
# Empty file(s):
rm '/home/sam/Pictures/zero.txt'
# Duplicate(s):
ls '/home/sam/Pictures/2024/IMG_0412.jpg'
rm '/home/sam/Pictures/phone-backup/IMG_0412.jpg'
ls '/home/sam/Pictures/scan (1).pdf'
rm '/home/sam/Pictures/scan.pdf'
==> Note: Please use the saved script below for removal, not the above output.
==> In total 7 files, whereof 2 are duplicates in 2 groups.
==> This equals 13 B of duplicates which could be removed.
==> 3 other suspicious item(s) found, which may vary in size.
Wrote a json file to: /home/sam/rmlint.json
Wrote a sh file to: /home/sam/rmlint.shRead each duplicate group as: the ls line is the original rmlint will keep, the rm lines are the copies the script would remove. Look at the second group: rmlint chose to keep scan (1).pdf and remove scan.pdf, which is probably not what you would pick. Nothing on disk has changed yet, and the originals section shows how to steer that choice. Notice also that the default scan also reports empty files, empty folders, and broken symlinks. That surprises people who only wanted duplicates; the types section shows how to turn it off.
The two output files land in the directory you ran rmlint from, not the one you scanned. Run it from a scratch directory such as ~/dedupe so the scripts do not end up inside the folder you are cleaning.
Review and Run rmlint.sh
The script is plain shell. Each duplicate group is one original_cmd line followed by one remove_cmd line per copy, so grep gives you a readable plan:
$ grep -E '^(original_cmd|remove_cmd)' rmlint.sh
original_cmd '/home/sam/Pictures/2024/IMG_0412.jpg' # original
remove_cmd '/home/sam/Pictures/phone-backup/IMG_0412.jpg' '/home/sam/Pictures/2024/IMG_0412.jpg' # duplicateThen do a dry run, and only after that the real thing:
# Print every action, change nothing (implies -d and -x)
./rmlint.sh -n
# Run it: shows a warning and waits for input
./rmlint.shWithout -d, the script prints a warning and asks you to "type any string to continue"; pressing Enter or Ctrl-D aborts. The options it accepts (from ./rmlint.sh -h):
| rmlint.sh option | What it does |
|---|---|
-n | Dry run: print what would be done, change nothing |
-d | Do not ask before running |
-x | Keep rmlint.sh afterwards (by default it deletes itself when it finishes) |
-p | Re-check that each duplicate is still identical to its original before removing it |
-c | Clean up directories left empty by the deletions |
-k | Keep the timestamps of directories when removing duplicates |
-q | Hide the progress display |
Use -p if any time has passed between the scan and the run. Files that changed in between would otherwise be removed on the strength of an old scan.
Choose What rmlint Looks For
The -T (--types) option picks the kinds of lint. Each type has a short code:
| Type | Code | Finds |
|---|---|---|
duplicates | df | Files with identical contents |
duplicatedirs | dd | Whole directories with identical contents (same as -D) |
emptyfiles / emptydirs | ef / ed | Zero-byte files / folders with nothing in them |
badlinks | bl | Symlinks that point nowhere |
badids | bi | Files owned by a user or group that no longer exists |
nonstripped | ns | Binaries with debug symbols (not in the default set) |
# Duplicate files only
rmlint -T df ~/Pictures
# Duplicate directories only
rmlint -T dd ~/backups
# Everything except empty files and empty dirs
rmlint -T "all -ef -ed" ~/DownloadsFor duplicate trees, rmlint -D dir1 dir2 reports whole folders instead of hundreds of individual files, and the script removes the copy with one rm -rf:
$ rmlint -D d1 d2
# Duplicate Directorie(s):
ls -la '/home/sam/d1'
rm -rf '/home/sam/d2'Control Which Copy rmlint Keeps
By default rmlint ranks each group with -S pOma: the path you listed first on the command line, then fewest hard links outside the group, then the oldest modification time, then alphabetical order. That is reasonable for one folder, but for "keep the archive, clean the dump" you want to say so explicitly. Paths after // are tagged, and tagged paths always win:
# Remove from new/ anything archive/ already holds.
# -k: never delete from tagged paths (archive)
# -m: only report groups that have a copy in archive
$ rmlint -T df new // archive -k -m
$ grep -E '^(original_cmd|remove_cmd)' rmlint.sh
original_cmd '/home/sam/archive/a.txt' # original
remove_cmd '/home/sam/new/a.txt' '/home/sam/archive/a.txt' # duplicateIn the test above, new/ also held two identical copies of b.txt. Without -m, rmlint would have marked one of them for removal too, because -k only protects the tagged side. With -m it leaves duplicates that exist only inside new/ alone. To change the ranking instead, pass your own letters, such as -S M to keep the newest copy, or -S l to keep the shortest file name.
rmlint tells you which files are identical. To see what is missing from one folder or has changed, see how to compare folders on Linux.
Link Duplicates Instead of Deleting Them
The script's behavior is set by a handler. The default is remove. Change it with -c sh:handler=... or one of the shortcuts:
# Try reflink/clone first, fall back to hard link, then symlink
rmlint -T df -c sh:link ~/Pictures
# Hard link, falling back to symlink
rmlint -T df -c sh:hardlink ~/Pictures
# Script now contains lines like:
cp_hardlink '/home/sam/Pictures/phone-backup/IMG_0412.jpg' '/home/sam/Pictures/2024/IMG_0412.jpg' # duplicateOn ext4, sh:link ends up hard-linking because the filesystem has no reflinks; on Btrfs or reflink-enabled XFS it clones, so the copies share disk blocks but stay independent when edited. With a hard link, editing the file through one name changes it under the other, so use it for read-only material such as photo archives and install media. You can also send duplicates to the desktop trash instead of deleting them:
# Needs the trash-cli package; $1 is the duplicate, $2 the original
rmlint -T df -o sh -c sh:cmd='echo "Trashing $1" && trash-put "$1"' ~/Pictures > trash.shrmlint Options Worth Knowing
| Option | What it does |
|---|---|
-T types | Choose lint types (see above) |
-D | Find and merge duplicate directories |
--hidden | Include hidden files and folders (off by default) |
-s 1M-1G | Only consider files within a size range (units such as K, M, G) |
-d N | Limit how deep rmlint recurses |
-x | Do not cross into other filesystems or mounts |
-e / -b | Only match files with the same extension / the same base name |
-a name / -p | Pick the hash algorithm / compare byte by byte (paranoid) |
-S criteria | Rank originals (default pOma) |
-k / -m | Keep everything in tagged paths / only report groups with a tagged copy |
-g | Show a progress bar instead of the list |
-o fmt[:file] / -O fmt[:file] | Replace / add outputs: sh, json, csv, fdupes, uniques, py, summary |
-C | Cache checksums in extended attributes to speed up repeat scans |
--gui | Start the Shredder GUI (needs the GUI package) |
Two output tricks are handy in scripts. rmlint -T df -o fdupes ~/Pictures prints groups separated by blank lines, exactly like fdupes, and -o csv prints each file with its size and checksum. Note that -o replaces the default outputs, so add -O sh:rmlint.sh if you still want the script.
rmlint vs fdupes and jdupes
| rmlint | fdupes | jdupes | |
|---|---|---|---|
| How deletion happens | Writes a script you review and run | Deletes directly (-d, -dN) | Deletes directly (-d, -dN) |
| Other lint | Empty files and dirs, broken links, bad IDs | No | No |
| Duplicate directories | Yes (-D) | No | No |
| Links instead of deleting | Hard link, symlink, reflink, clone | No | Hard link, symlink, reflink |
| Keep one side | Tagged paths with //, -k, -m | Post-process the output | -I and -O |
| Native Windows build | No (WSL) | No (WSL) | Yes |
Pick rmlint when you want to read the plan before it runs or clean up more than duplicates. fdupes is the simplest to learn (see the fdupes guide), and jdupes is the one to use on Windows without WSL.
Before You Run rmlint on Real Data
Mistakes that cost data
- Running the script without reading it. The default scan also targets empty files, empty folders, and broken symlinks. Some programs rely on empty marker files. Use
-T dfif you only meant duplicates. - Running an old script. Files can change between scan and run. Re-scan, or run with
./rmlint.sh -pso each pair is re-checked first. - Trusting the default original. Oldest-modified is not always the copy in your tidy folder. Tag the folder to keep with
//and add-k. - -D with -c sh:clone. The manual says these cannot be combined; merging directories uses removal.
Also point rmlint at your own documents, photos, and downloads, not at / or a whole home directory. Package caches, node_modules, git objects, and application data contain duplicates and empty files on purpose.
When You Want a Plan With Undo
rmlint's script-first design is the safest of the classic command-line tools, but the script runs rm, and once it has run there is no going back. On a family photo archive or a shared drive you may want to see the groups side by side, decide folder by folder, and be able to reverse it.
FolderManifest is a desktop app for Windows 10/11, macOS, and Linux that finds duplicates the same strict way, by exact SHA-256 content match, and turns the clean-up into a plan you review and approve, with undo. Like rmlint, it does not detect similar photos or re-encoded audio; for those, use Czkawka or dupeGuru. It does not hard-link or reflink files or hunt for broken symlinks, which rmlint does. It does compare folders and verify copies and backups against a SHA-256 manifest, which rmlint does not.
You may not need it
If you are comfortable in a terminal and have a backup, rmlint with a -n dry run is enough for most clean-ups, and it is free. A reviewable plan with undo is worth it when the files are irreplaceable or someone else has to sign off on what gets removed.
Frequently Asked Questions
What is rmlint?
rmlint is a free, open-source command-line tool for Linux, macOS, and other Unix systems that finds duplicate files and other "lint": duplicate directories, empty files, empty directories, broken symlinks, files with a bad user or group ID, and non-stripped binaries. It does not delete anything itself. It writes a shell script, rmlint.sh, that you review and then run.
Does rmlint delete files?
No. The rmlint command only scans and reports. It writes rmlint.sh and rmlint.json to the current directory. Files are removed only when you run ./rmlint.sh, and that script shows a warning and waits for you to type something before it starts. Run ./rmlint.sh -n first for a dry run that changes nothing.
Which copy does rmlint keep?
The original in each group is chosen by the --rank-by (-S) criteria, which default to pOma: the path given first on the command line, then the file with the fewest hard links outside the group, then the oldest modification time, then alphabetical order. Paths placed after // on the command line are "tagged" and always win, so rmlint new // archive keeps the copy in archive.
What is the difference between rmlint and fdupes?
fdupes finds duplicate files and deletes them itself, either interactively with -d or automatically with -dN. rmlint also finds empty files and folders, broken symlinks, and duplicate directories, and it never deletes during the scan: it writes a reviewable script. rmlint can also replace duplicates with hard links, symlinks, or reflinks, which fdupes cannot, and it can print fdupes-style output with -o fdupes.
How do I install rmlint?
On Debian and Ubuntu run sudo apt install rmlint (and rmlint-gui for the Shredder GUI). On Fedora use sudo dnf install rmlint, and on macOS brew install rmlint. Arch users get it from the AUR. Packaged versions vary by distribution; if yours is missing, build it from the GitHub source with scons.
Does rmlint work on Windows?
There is no native Windows build. The project targets Linux, BSD, macOS, and other Unix systems. On Windows 10 or 11 you can install it inside WSL (sudo apt install rmlint in Ubuntu) and scan Windows drives through /mnt/c, though scanning across that boundary is slower than a native tool.
Does rmlint find similar photos?
No. rmlint matches files whose contents are identical, using a hash and optionally a byte-by-byte check. A resized photo or a re-encoded song counts as a different file. For near-duplicates use a similarity tool such as Czkawka or dupeGuru.
Find Exact Duplicates, Review the Plan, Keep an Undo
SHA-256 duplicate detection with a clean-up plan you approve before anything moves. Windows, Mac, and Linux. 7-day free trial, no card required, 30-day money-back guarantee.
