Insight: Useful Tools to Find and Delete Duplicate Files in Linux
Let’s have a quick look into the list of best and useful tools to find and delete duplicate files in Linux based operating system.
Useful Tools To Find And Delete Duplicate Files In Linux
1. Fdupes – Scan for Duplicate Files in Linux
We can use Fdupes tool in Linux to find and delete duplicate files. It is free and open source tool to search duplicate files in Linux based operating systems.
Install fdupes on a Linux
Run the following commands to install fdupes on Linux based operating systems.
sudo apt-get install fdupes
yum install fdupes dnf install fdupes [On Fedora 22+]
Now, run the following command to search the file in specific directory.
sudo fdupes <directory name>
To search files recursively.
sudo fdupes -r <directory name>
To delete all duplicates use the
-d option like this. You need to carefully follow the on screen instructions.
sudo fdupes -d <directory name>
To search in multiple directories.
sudo fdupes <directory1> <directory2>
To calculate the size of the duplicate files.
sudo fdupes -S <dir>
Rdfind is another tool to search duplicate files in Linux and delete it from the system. Along with the filenames, It uses checksum and find duplicates based on file contains.
Install Rdfid in Linux based operating system.
Run the following command to install Rdfid in Linux:
sudo apt-get install rdfind
sudo yum install epel-release && sudo yum install rdfind
[On Fedora 22+]
sudo dnf install rdfind
Run the following command to search the duplicate files in a specific directory. It will save the results in file called results.txt located in the same directory.
sudo rdfind /home/user
You can also use the
-dryrun option to provide a list of duplicates without taking any actions:
sudo rdfind -dryrun true /home/user
and replace them with hardlinks.
sudo rdfind -makehardlinks true /home/user
To delete the duplicates.
$ rdfind -deleteduplicates true /home/user