How to delete duplicate files in Linux

16 Feb, 2010

terminal icon
Question: Two of my directories on my server have some the same files. How can I easily delete any duplicates while preserving the unique files?

Answer: There exists a Linux tool for just about everything, and this is no exception. You need a tool called fdupes, which searches the path you give it for duplicate files and uses several comparison techniques (sizes, MD5 signatures, byte-by-byte comparison) to find and eliminate duplicates.

First install fdupes. In RHEL/Fedora/CentOS, use the rpmforge repository enter:

# yum install fdupes

To find duplicates in the /etc directory, you would enter:

# fdupes /etc

To force fdupes to prompt you whether to preserve or delete files:

#fdupes -d /etc

As you can see, fdupes might be just what you need to clean up your server and possibly increase that precious disk space.

Source: nixCraft
Photo: Wikimedia Commons

Share
Categories : Software, VPS & Dedicated , , , , , , ,
Tag: , , , , , , ,

Comments are closed.