How to find and delete duplicate files in Ubuntu/Linux

Massively duplicated files are oftentimes a problem with music and movie collections. Because hunting for dupes by hand is definitely not the way to go, you may want to look to command-line tools like fdupes for help.

fdupes is available via apt-get in Ubuntu, so install it first:

sudo apt-get install fdupes

This is the basic syntax for looking up duplicated files:

fdupes -r [target-directory]

How to delete all duplicates and generate a report at the same time:

fdupes -rdN [target-directory] > textfile.txt

A quick overview of what the options mean:

  • -r recursive, traverse subdirectories
  • -d delete, delete duplicates
  • -N keep the first file, remove other (duplicate) files

Needless to say: use this with caution! Files will be deleted forever.

Find more information on fdupes here (UbuntuGeek).


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s