The rdfind (short for redundant data find) is a command line tool used to find duplicate files in a directory tree. It's particularly useful for cleaning up space by identifying and optionally removing redundant files. This tutorial explains how to install rdfind on Ubuntu 24.04.
Install rdfind
Execute the following command to refresh the package lists:
sudo apt update
Install rdfind:
sudo apt install -y rdfind
To verify the installation, check the rdfind version using the following command:
rdfind --version
Testing rdfind
To understand how rdfind works, let's create a simple test case with duplicate files:
mkdir test_dir
echo "Hello" > test_dir/test.txt
cp test_dir/test.txt test_dir/test2.txt
cp test_dir/test.txt test_dir/test3.txt
Run rdfind to scan for duplicates:
rdfind test_dir
By default, rdfind generates a results file named results.txt
. Let's take a look at its contents:
cat results.txt
Here's what the output looks like:
# Automatically generated
# duptype id depth size device inode priority name
DUPTYPE_FIRST_OCCURRENCE 1 0 6 51 22441372 1 test_dir/test.txt
DUPTYPE_WITHIN_SAME_TREE -1 0 6 51 22441373 1 test_dir/test2.txt
DUPTYPE_WITHIN_SAME_TREE -1 0 6 51 22441374 1 test_dir/test3.txt
# end of file
This tells us that test2.txt
and test3.txt
are duplicates of test.txt
.
Now let's remove the duplicate files, keeping just the first occurrence:
rdfind -deleteduplicates true test_dir
You should see output similar to this:
It seems like you have 3 files that are not unique
Totally, 12 B can be reduced.
Now making results file results.txt
Now deleting duplicates:
Deleted 2 files.
Uninstall rdfind
If you want to fully uninstall rdfind, execute the following command:
sudo apt purge --autoremove -y rdfind
Leave a Comment
Cancel reply