Linux Mint

Find and Remove File Duplicates in Linux Mint

Organizing the system is a difficult task if you have the habit of downloading stuff from the internet and storing the files and images on your device. This might cause a mess in your directories with the duplicated files and it becomes even tougher. The large files occupy the storage and might create disk full issues.

The easiest and most straightforward way of managing the files is to find and delete the file’s duplicates using the dedicated file finder to perform this task more efficiently. In this guide, you will learn how to find and delete the files in the Linux Mint via the command line.

How to Find and Remove File Duplicates in Linux Mint

To get rid of duplicate files we need good software, the following two command line utilities find the duplicate files and delete them:

1: How to Find and Remove Files Duplicates in Linux Mint Using rdfind

The rdfind stands for redundant data finder and is the open-source command line utility for finding the duplicate files within the directories. It finds duplicate files based on their contents and not the name. It uses the algorithm for identifying which file is the original and considers the remaining files as duplicates. Install the rdfind on the Linux Mint via the following command:

sudo apt-get install rdfind

 

The rdfind will save the results in the results.txt file and present them in the same directory. Use the following syntax for finding the duplicate files in Linux:

rdfind <path>

 

You have to mention the path. In the below example, I am finding and deleting duplicate files in the Documents directory. So first, execute the below command to identify the duplicate files:

rdfind Documents

 

The dry run will provide you the list of the duplicated files without taking any action:

rdfind -dryrun true Documents

 

Once you have identified the duplicate files, make the hard links:

rdfind -makehardlinks true Documents

 

For deleting the duplicate files, run the following command:

rdfind -deleteduplicates true Documents

 

If you want to explore more about the rdfind execute the below command to open the manual of this tool:

man rdfind

 

2: How to Find and Remove Files Duplicates in Linux Mint Using fdupes

It is also a reliable and easiest program for Linux users for finding duplicate files. This program compares the bytes by bytes to identify the duplicates. fdupes also provide you a brief overview of the duplicate files. In Linux Mint you can install it via apt:

sudo apt install fdupes

 

For findings the duplicate file in the current directory, use the following command:

fdupes -r ./

 

If you want to identify the duplicate files in the specific directory use the following command. Here I am finding the files in Documents:

fdupes -r ~/Documents

 

To delete the duplicate files in the document folder, run the following command:

fdupes -d ~/Documents

 

For each set of files, this tool will display the list and ask you to choose which files you want to keep.

Conclusion

At some point we come across storage full issues on the system. Duplicate files occupy a lot of space on your system, with the above-mentioned utilities you can find them and remove them. Ensure to follow the steps properly and be extra careful to avoid deleting important documents on the system.

About the author

Zainab Rehman

I'm an author by profession. My interest in the internet world motivates me to write for Linux Hint and I'm here to share my knowledge with others.