Hello, friends. Working in the terminal is common for all of us who work with Linux servers. However, in between uses, there may be tricks that we have overlooked or simply don’t know about. That’s why, in this post, we’re going to show you how to find duplicate files in Linux.
Introducing to fdupes
To make our goal easier to achieve, we need a tool called
According to the tool’s Github profile
FDUPES is a program for identifying duplicate files residing within specified directories.
within specified directories.
It is an open-source application whose code we can analyze and use for our purposes. It is created in C language so it is a very fast and efficient tool.
Although the development of this application is not very active, it is very efficient. In addition to this we can use it on almost any Linux-derived system through binaries or by compiling the source code by ourselves.
So, let’s go for it.
Install fdupes on Linux
To use the
fdupes command we have to install the package on our system.
If you are using Debian, Ubuntu, Linux Mint, or any of these derivatives, then you can install it as follows
sudo apt update sudo apt install fdupes
In case you are using an RHEL-derived distribution such as CentOS Stream, RockyLinux, AlmaLinux, or even Fedora, you have to run
sudo dnf install fdupes
But in case you are using Gentoo and derivatives
sudo zypper in fdupes
Finally on Arch Linux and derivatives like Manjaro
sudo pacman -S fdupes
As the program is so light, you will have it on your system very quickly.
How to find duplicate files in Linux
To check all the available options provided by
fdupes you have to run this command
This way, you will have access to a brief description of the options and a basic syntax that you have to follow to use the command.
Although there are a lot of options, the reality is that the command is quite simple to use and accomplishes its goal very easily.
So, to find out which are the duplicate files in a specific location, you have to run, something similar to this
/home/angelo is a test directory that you have to replace.
Also, you can search two or more directories simultaneously if you separate them with a blank space.
fdupes /home/angelo/Documents /home/angelo/Pictures
This will list duplicate files that appear in both directories.
It is also possible to recursively search and scan the directories with the
fdupes -r /home/angelo/
This will list all duplicate files in each of the subfolders of the path.
Many people locate duplicate files to remove them. By adding the
-d option we can do this in one go.
fdupes -rd /home/angelo/
However, the developer of the application warns us that
When using -d or –delete, care should be taken to insure against
accidental data loss
But what if we want to know the size of these files? Well, thanks to the
-m option it is a very easy task.
fdupes -m /home/angelo/
So, this way we can use
fdupes and find out the duplicate files in Linux.
Duplicate files in Linux – Conclusion
The terminal is wonderful and thanks to it, we can even use it for file comparison to find out which files are duplicates thanks to
So, enjoy it,