It’s quite common to end up with many copies of the same file on your computer while working with huge volumes of media and documents.
Eventually, you’ll end up with a mess of files and an additional storage shortage due to duplicate files, prompting you to run a duplicate file check on your system.
Checking for duplicate files manually is not an option for obvious reasons. You can use a variety of programs to discover and delete duplicate files to accomplish this.
In this article, you will learn to manage your duplicate files with fdupes, which is a Linux software that not only detects duplicates but also gives you multiple options to deal with them.
- A Linux-based system
- Terminal access
- A user account with sudo privileges.
Note: The commands in this tutorial are executed on the Ubuntu 20.04 system. All the instructions in the tutorial are valid for any Linux-based system.
Install Fdupes in Ubuntu
The fdupes installation package comes with all major Linux distributions. To install fdupes in Ubuntu, simply run the following apt command.
sudo apt install fdupes sudo apt install fdupes
Find Duplicate Files With Fdupes
Once the installation is finished, you can now use fdupes to identify duplicate files. To find duplicate files, run the following command with your directory path.
fdupes <directory path>
You can see the duplicate files presented in the output.
Search for Duplicate Files in Subfolders With Fdupes
The above command only finds duplicate files within the current folder. It does not look through the subfolders and such. To find duplicates throughout the folder and subfolders, you need to run the fdupes command with the -r option.
fdupes -r <directory path>
You can see from the output that the “-r” option does a more thorough search for duplicates in the folders and subfolders.
Search for Non-Empty Duplicate Files With Fdupes
You can also search for non-empty duplicate files. This will help you focus on the task and you will not have to deal with empty files. To use this option, use the following command.
fdupes -n <directory path>
Get Information About Duplicate Files With Fdupes
Run the fdupes command with the -m option to get more information on the set of duplicate files.
fdupes -m <directory path>
You can also run the fdupes command with the -S option to get size information about the duplicate files.
fdupes -S <directory path>
Run the following command to save the fdupes command’s outputs.
fdupes <directory path> > output.txt
Delete Duplicate Files With Fdupes
Once you have narrowed down the duplicates in the directory, you can delete the duplicates by running the fdupes command with the -d option.
fdupes -d <directory path>
You will be prompted to preserve versions out of the duplicate files list. Simply enter the file number mentioned in the list to preserve the file.
Advanced Options in Fdupes Command
You can run the fdupes commands with multiple options to avail of the offered benefits. Such as, you can find out all the non-empty files in the folders and subfolders with the following command.
fdupes -n -r <directory path>
Or get overall information about all the duplicate files within the folders and subfolders.
fdupes -m -r <directory path>
File organization is a time-consuming process in and of itself. When you factor in the time and work it takes to organize your disorganized storage, you are looking at a few hours of wasted time and effort.
However, owing to applications like fdupes, identifying duplicate files and deleting them has never been easier or more efficient. The instructions in this article will provide you with multiple options on how you can treat your duplicate files.