Categories: DesktopShellUbuntu

Find and Replace Duplicate Files in Ubuntu 18.04 LTS

Sometimes our systems are loaded with the same files residing in different locations, eating up our memory resources. There are instances when we download a file to a location and then re-download and save it to some other location. We often forget that many files with the same name might be existing on our system without us knowing the exact location. If you are using your system for a while, these duplicate files may take a lot of space and create a large clutter. When we want to clear the clutter, it is a very burdensome task to manually look up for duplicate files and then delete them. However, Ubuntu supports many open-source applications that you can use to locate and delete any such files.

In this article, we will introduce you to two such applications named FSlint and fdupes that let you locate and delete redundant files from your system. We are running the commands and steps described in this article on an Ubuntu 18.04 LTS (Bionic Beaver) system.

FSlint - a GUI and Terminal based solution

In order to install FSlint, open your Ubuntu Terminal through the Dash or by pressing Ctrl+Alt+T and enter the following command:

$ sudo apt install fslint

Enter y when prompted with a y/n option in order to continue installation. Once the installation is complete, you can access both the FSlint Janitor graphical application and FSlint command line utility.

FSLint Janitor

In your Ubuntu Dash, enter fslint in order to access the graphical application FSlint Janitor that helps you get rid of not only duplicate files, but also empty directories, files with incorrect names, and temporary files etc.

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

You can then choose to select and delete the files you want to get rid of.

FSlint Command Line

In order to access the command line utility FSlint, move to the directory where it is located by entering the following command in your Ubuntu Terminal.

$ cd /usr/share/fslint/fslint

Once you are 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..

You can then delete the unwanted files on your own. It is best to run this utility as a root user so that you can access all the files without facing authorization issues.

Fdupes - a Terminal-based solution

Unlike FSlint that can be operated both graphically and through the command line, Fdupes is a powerful yet only a simple Terminal based utility. It lists all the redundant file and lets you delete the ones you want to. Run the following command in order to list all the redundant files:

$ fdupes [directorylocation]

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

$ sudo apt install fdupes

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

You can then delete the redundant files on your own.

You can also make use of various switches along with this command in order to ease your search and deletion. For example, using the -d switch will give you an option to delete duplicate files and preserve the one you want to keep.

Running this utility as a root user is preferable in order to avoid authorization issues. If you want to list duplicate files from the sub-directories as well, you can use the -r switch as follows:

This is how the two utilities FSlint and fdupes let you clear the clutter on your system to make space for more important data, by getting rid of all the duplicate files residing on your system.

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn

Recent Posts

How to Install Magento 2 on AlmaLinux

Magento is a free and open-source e-commerce platform written in PHP. It is simple, easy…

1 year ago

How to Install ISPConfig Hosting Control Panel with Apache Web Server on Ubuntu 24.04

ISPConfig is an open-source control panel that allows users to manage multiple servers from a…

1 year ago

How to Test your Email Server (SMTP) Using the Telnet Command

As a Linux administrator, you may find it necessary to troubleshoot or test your Simple…

1 year ago

Managing Network Interfaces and Settings on Ubuntu 24.04 with nmcli

Ubuntu 24.04, like many modern Linux distributions, relies on the NetworkManager for managing network connections.…

2 years ago

Using Restic Backup on Ubuntu 24.04

Restic is a modern, open-source backup program designed for efficiency, security, and simplicity. It enables…

2 years ago

Installing phpMyAdmin on Rocky Linux 9 and Securing it with Let’s Encrypt SSL

phpMyAdmin is a popular free tool written in PHP intended to administer MySQL and MariaDB…

2 years ago