Just Start Typing Text and Press Enter

Menu
Close
Aug 23, 2019

How to Remove Duplicate Files on Linux the Easy Way

0 Comment | By
Linux Remove Duplicate Files and Folders

Recently on my own network I realized that I could possibly have a ton of duplicate files over my local Linux systems. In my attempts to find and locate these files I stumbled over some software called FDUPES would help me locate these duplicates and proceed with remove them. Doing this helped me save over 300MB of disk space and it’s my hopes it can help you save unused disk capacity for you too!

Getting started:

First off before you proceed with the steps that I provided be sure to make a backup of the particular directory or linux system before you get started. As always this article was created “as is” and I will not be liable for ANY data loss or negative repercussions that happen by following my instruction below.

In the content below we will use the path: /var/www/html/music as an example however you can put in your own path where every it may be as /the/path/you/want

First off let me speak to the software that I mentioned earlier. FSlint can be executed via the CLI or GUI and it has a set of commands that can be executed on both interfaces. It will help you find and remove duplicate files or directories with names that may or may not be incorrect.

Installation:

You can begin with the installation via CLI or you can head over to the FSlint website. Since you are on my site you know that I do not administer any of my linux systems via a desktop so let’s get it installed via the CLI (command line).

Finding and Removing Duplicate Files:

  • Open the terminal on your linux system
  • Run the follow to ensure that you are getting the latest packages: sudo apt-get update -y
  • Then proceed with installing the FSlint software (Ubuntu or Raspberry Pi): sudo apt-get install fslint -y
  • If you are running the Fedora Distro run: dnf install fdupes
  • Once the software is installed you can proceed by running the following command to test: fdupes /var/www/html/music This will give you a nice list like:
    • /var/www/html/music/file1.mp3
    • /var/www/html/music/file2.mp3
    • /var/www/html/music/file3.mp3
    • /var/www/html/music/file4.mp4
  • Moving forward using flag -r in the command is simply to search recursively the files in that directory however you will need to proceed with manually deleting these files yourself: fdupes -r /var/www/html/music
  • Moving on to finding and deleting the particular duplicate files you will need to use the -d flag. The -d flag will proceed with locating the files and will prompt you on which particular file that you wish to keep: fdupes -d /var/www/html/music

Conclusion:

Well not much else to say but this is a simply and easy way to find and remove duplicate files on your linux system with FSLint. If you have a more efficient way, and I certainly know a few do place in the comments below. In a future post I will work on a more advanced way using md5 sums.

DON'T MISS ANY UPDATES