Find and replace duplicate files in Ubuntu 18.04 LTS

Sometimes our systems are loaded with the same files in different places, consuming our memory resources. There are times when we upload a file to a specific location and then re-upload and save it elsewhere. We often forget that many files with the same name can exist on our system, and we do not know their exact location. If you’ve been using your system for a while, these duplicate files can take up a lot of space and create a lot of clutter. When we want to clean up clutter, it is a very cumbersome task to manually search for duplicate files and then delete them. However, Ubuntu supports many open source applications that can be used to find and delete any such files.

In this article we will introduce you to two such applications, FSlint and fdupes, that allow you to find and remove redundant files from your system. We are following the commands and steps in this article on an Ubuntu 18.04 LTS (Bionic Beaver) system.

FSlint – GUI and Terminal Based Solution

To install FSlint, open your Ubuntu terminal via Dash or by pressing Ctrl + Alt + T and enter the following command:

$ sudo apt install fslint

Install fslint

Enter y when prompted with the ay / n parameter to proceed with the installation. Once the installation is complete, you can access both the FSlint Janitor graphical application and the FSlint command line utility.

FSLint Janitor

In Ubuntu Dash, type fslint to access the FSlint Janitor graphical application, which will help you get rid of not only duplicate files, but also empty directories, files with incorrect names, temporary files, etc.

fslint app search

The Duplicates option in the left pane is selected by default. All you need to do is specify the path and click the Find button.

Find duplicate files with fslint in Ubuntu

Then you can select and delete the files you want to get rid of.

FSlint Command Line

To access the FSlint command line utility, change to the directory where it is located by entering the following command in the Ubuntu terminal.

$ cd /usr/share/fslint/fslint

Once in the fslint directory, you can run the utility using the following syntax:

$ ./fslint /[directorylocation]

Example:

$ ./fslint /home/[name]

Replace [name] with your Ubuntu username in the above example ..

Finding duplicate files in the shell

Then you can delete unnecessary files yourself. It is best to run this utility as root so that you can access all files without authorization issues.

Fdupes – terminal based solution

Unlike FSlint, which can be manipulated both graphically and through the command line, Fdupes is a powerful yet simple terminal-based utility. It lists all the redundant files and you can delete the ones you want. Run the following command to list all redundant files:

$ fdupes [directorylocation]

If after running this command you get the following message, you need to first install the utility using this command:

$ sudo apt install fdupes

Install fdupes

This is how you can check a directory for redundant files:

Use fdupes to scan a directory for duplicate files

Then you can delete the redundant files yourself.

You can also use various switches along with this command to make searching and deleting easier. For example, using the -d switch will give you the option to remove duplicate files and keep the one you want to keep.

Remove duplicate files with fdupes

Running this utility as root is preferable to avoid authorization problems. If you want to list duplicate files from subdirectories, you can use the -r switch like this:

Recursive search for duplicate files

This is how the two utilities FSlint and fdupes allow you to clean up the clutter on your system to make room for more important data by getting rid of all the duplicate files on your system.

Find and replace duplicate files in Ubuntu 18.04 LTS

Sidebar