Linux Commands and Scripts

How To Find and Delete Duplicate Files in Linux

In this tutorial, we will see how to find and delete duplicate files in Linux with rdfind tool.

For this demonstration, we will use Rdfind tool. It is find duplicate files in Linux. Rdfind comes from redundant data find. It is a free tool used to find duplicate files across or within multiple directories. It used a checksum and finds duplicates based on file contains not only names. The rule is A letter rank higher.

Let’s get started

Install rdfind

We need to install rdfind tool before we start using it.

# apt-get install rdfind     [On Debian/Ubuntu]

# yum install epel-release && yum install rdfind    [On CentOS/RHEL]

To run rdfind on a directory simply type rdfind and the target directory.

# rdfind /home/user

Display list of duplicates without taking any actions

With dryrun option, you can get a list of duplicates without taking any actions. It will be easy to check first and remove it.

# rdfind -dryrun true /home/user

Replace duplicates with hardlinks

You can find and replace duplicates with hardlinks by using following command

# rdfind -makehardlinks true /home/user

Delete the duplicates

If you want to delete duplicates, run following command

# rdfind -deleteduplicates true /home/user

For more details about rdfind

# man rdfind

In this article, we have seen how to find and delete duplicate files in Linux with rdfind tool.

[Need assistance to fix this error or install tools? We’ll help you.]

Related Articles