Software & AppsOperating SystemLinux

How To Automatically Sync Two Directories in Ubuntu

Ubuntu 1

In this article, we will explore how to automatically sync two directories in Ubuntu. This can be incredibly useful for creating backups, mirroring directories for development work, or simply keeping files up to date across different locations. We will primarily focus on two popular tools: Unison and FreeFileSync.

Quick Answer

To automatically sync two directories in Ubuntu, you can use tools like Unison or FreeFileSync. Unison offers a powerful command-line interface for two-way syncing, while FreeFileSync provides a user-friendly GUI. Both tools allow you to compare and synchronize directories, keeping your files up to date across different locations.

Unison: A Powerful File Synchronization Tool

Unison is a highly efficient file-synchronization tool that allows for two-way syncing between directories. It supports both GUI and terminal-based interfaces and works seamlessly across different operating systems.

Installing Unison

To install Unison on Ubuntu, open your terminal and run the following command:

sudo apt-get install unison

This command uses the apt-get package manager to install Unison. The sudo prefix is used to run the command with administrative privileges.

Using Unison

After installation, you can start syncing directories. To do this, use the following command:

unison /path/to/directoryA /path/to/directoryB

Here, /path/to/directoryA and /path/to/directoryB are the paths to the directories you want to sync. Unison will compare the two directories and make them identical by copying, deleting, or updating files as necessary.

FreeFileSync: An Open-Source Data Backup Software

FreeFileSync is another excellent tool for synchronizing files and folders. It provides a visual interface, making it a more user-friendly option than Unison. It’s available for Windows, Linux, and macOS.

Installing FreeFileSync

To install FreeFileSync, download the latest version from the official FreeFileSync website. Once downloaded, extract the archive and run the installer.

Using FreeFileSync

After installation, open FreeFileSync. The interface is divided into two panels. You can select your directories by clicking on the ‘Browse’ button in each panel. After selecting your directories, click on the ‘Compare’ button to find differences between the directories.

Once the comparison is done, click on the ‘Synchronize’ button. A dialog will pop up, allowing you to choose the type of synchronization you want. For a two-way sync, select ‘Two way’. This will update both directories to match each other exactly.


Both Unison and FreeFileSync are powerful tools for syncing directories in Ubuntu. While Unison is more suited to those comfortable with command-line interfaces, FreeFileSync provides a user-friendly GUI that may be more appealing to some users. Regardless of your preference, both tools are capable of keeping your directories in sync.

Remember, when implementing a two-way sync, always exercise caution to avoid accidental deletion of files. Consider using backup strategies or version control systems to mitigate the risk of data loss.

By following the steps outlined in this article, you should now be well-equipped to automatically sync two directories in Ubuntu.

Can I use Unison to sync directories on different operating systems?

Yes, Unison supports syncing directories across different operating systems.

Is FreeFileSync available for macOS?

Yes, FreeFileSync is available for macOS in addition to Windows and Linux.

Can I sync more than two directories using Unison or FreeFileSync?

Yes, both Unison and FreeFileSync allow for syncing multiple directories. Simply specify the paths to all the directories you want to sync.

Can I schedule automatic syncing with Unison or FreeFileSync?

Yes, both Unison and FreeFileSync offer options for scheduling automatic syncing. You can use tools like cron or task scheduler to set up recurring sync tasks.

Can I undo a sync operation using Unison or FreeFileSync?

Unison and FreeFileSync do not have built-in undo functionality. It is recommended to have backups of your directories before performing sync operations to avoid accidental data loss.

Can I use Unison or FreeFileSync to sync specific file types only?

Yes, both Unison and FreeFileSync allow for filtering based on file types. You can specify file extensions or patterns to include or exclude specific file types during the sync process.

Can I sync directories over a network using Unison or FreeFileSync?

Yes, both Unison and FreeFileSync support syncing directories over a network. You need to ensure that the necessary network protocols and permissions are set up correctly.

Can I use Unison or FreeFileSync to sync directories in real-time?

Unison and FreeFileSync are not designed for real-time syncing. They are typically used for periodic or manual syncing. For real-time syncing, you may need to explore other tools or solutions.

Leave a Comment

Your email address will not be published. Required fields are marked *