How to Install Unison File Synchronizer for Two-Way File Sync on Linux

Keeping files in sync across multiple machines is a common task for Linux users. You might use both a laptop and a desktop, manage a home server and a VPS, or just need an extra copy of your important files.

For simple backups, tools like rsync and scp work well, but if you make changes on both systems, one-way sync isn’t enough and you risk overwriting files or losing updates.

This is where Unison File Synchronizer is useful, which is a two-way synchronization tool that compares directories on both sides, detects changes, and updates them so that both locations always stay consistent.

This guide will walk you through the basics of using Unison File Synchronizer on Linux.

By the end, you’ll know how to:

  • Install Unison on popular Linux distributions.
  • Sync files between two local folders.
  • Synchronize directories across remote systems using SSH.
  • Create profiles to make recurring sync tasks easier.
  • Fix common issues like version mismatches and file conflicts.

Let’s get started…

Installing Unison on Linux

You can install Unison either from your Linux distribution’s package repository or by downloading the stable release. For most users, installing from the repository is the easiest method.

sudo apt install unison         [On Debian, Ubuntu and Mint]
sudo dnf install unison         [On RHEL/CentOS/Fedora and Rocky/AlmaLinux]
sudo apk add unison             [On Alpine Linux]
sudo pacman -S unison           [On Arch Linux]
sudo zypper install unison      [On OpenSUSE]    
sudo pkg install unison         [On FreeBSD]

If you want the GUI version, you can install it with the following command, but the GUI version (unison-gtk) is only available on Debian-based distributions.

sudo apt install unison-gtk

After installation, verify the version with:

unison -version

Important Note: Unison is strict about version compatibility. If you plan to sync between two systems (say, a laptop and a VPS), both must have the exact same version of Unison. Otherwise, it will refuse to connect.

Basic Local Synchronization

Before using Unison over a network, it’s a good idea to start with syncing two folders on the same machine, which will help you understand how Unison works without worrying about remote connections or SSH.

Let’s say you have two folders:

  • ~/Documents/work → your main working folder
  • ~/Backup/work_sync → your backup folder

To synchronize these folders, run:

unison ~/Documents/work ~/Backup/work_sync

Here is the breakdown of the command:

  • Comparison: Unison scans both directories and compares file names, sizes, and timestamps.
  • Reporting Differences: It lists all the differences between the two folders.
  • User Confirmation: If there are changes, Unison will ask you what to do: copy files from left to right, right to left, or skip them.
  • Synchronization: Once confirmed, Unison updates both directories so they match.

Tip: Files that exist only in one folder are automatically copied to the other. If files exist in both folders but have been changed differently, Unison will prompt you to resolve the conflict.

This two-way approach is what makes Unison safer than simply using cp or rsync in one direction. You can edit files on either side without worrying about losing updates.

Synchronizing Across Remote Systems (Using SSH)

Now let’s move to syncing files between two different machines over SSH, which means the connection is encrypted and secure.

You want to sync your local ~/Projects folder with a remote server:

unison ~/Projects ssh://username@server-ip//home/username/Projects

Here is the breakdown of the command:

  • ~/Projects → the local directory you want to sync.
  • ssh://username@server-ip//home/username/Projects → the full path on the remote machine, accessed via SSH.
  • Note the double slashes (//) after the hostname: they indicate a full path rather than a relative one.

Pro Tip: Set up SSH key-based authentication so you won’t have to enter your password every time, which is essential if you want to automate sync tasks later.

Using Profiles for Automation

Typing long Unison commands every time can get tedious. Luckily, Unison allows you to create profiles, which are saved sets of instructions for recurring sync tasks. Profiles are stored in ~/.unison/ with the .prf extension.

Creating a new profile file.

nano ~/.unison/work.prf

Add the following content:

root = /home/youruser/Documents/work
root = ssh://username@server-ip//home/username/Documents/work

auto = true
batch = true
prefer = newer

Here is the breakdown of the each option:

  • root → defines the folders to synchronize (local and remote).
  • auto = true → automatically performs synchronization without asking for confirmation.
  • batch = true → runs in non-interactive mode (useful for scripts or cron jobs).
  • prefer = newer → in case of conflicts, keeps the file with the most recent modification time.

Now you can simply run the following command and Unison will use your profile automatically, no need to type long commands each time.

unison work

Running Continuous Sync (Live Mode)

Sometimes you want your directories to stay in sync automatically as changes happen using a watch mode that monitors directories continuously.

unison work -repeat watch

With this command:

  • Unison keeps scanning your directories for changes.
  • Any file added or modified on either side is synced automatically.
  • This is particularly useful for development projects where files are constantly updated.

Note: Watch mode can consume more system resources if directories are very large, so use it wisely.

Scheduling Syncs with Cron

If you prefer periodic sync instead of continuous monitoring, you can schedule Unison to run automatically using cron jobs.

First, edit your crontab:

crontab -e

Add the following line to sync your profile every hour:

0 * * * * unison work -batch

Here is the breakdown of the command:

  • 0 * * * * → runs at the top of every hour.
  • unison work -batch → executes your work profile in non-interactive mode.

Common Unison Options You Should Know

Here’s a quick reference for useful Unison options:

Option Description
-auto Automatically resolve simple updates.
-batch Run without user prompts (useful for cron).
-ui text Force terminal text mode interface.
-repeat watch Continuously monitor folders for changes.
-prefer newer Keep the most recently modified file in case of conflict.

Example combining options:

unison work -auto -batch -prefer newer

This runs your sync automatically, resolves conflicts by keeping newer files, and doesn’t prompt you.

Why Choose Unison Over Other Tools

Tool Sync Type Two-Way GUI Available Use Case
rsync One-way Backup, server mirroring
Unison Two-way ✅ (GTK) Active projects across machines
Final Thoughts

Unison is a lightweight but powerful tool for anyone who needs to maintain consistency between multiple Linux machines. Unlike one-way tools such as rsync, it lets you safely sync files both ways, preventing accidental overwrites and file loss.

💡 Want to Level Up Your Linux Skills?

Check out Pro.Tecmint.com for ad-free reading, exclusive guides, downloadable resources, and certification prep (RHCSA, RHCE, LFCS) - all with lifetime access.

Ravi Saive
I'm Ravi Saive, an award-winning entrepreneur and founder of several successful 5-figure online businesses, including TecMint.com, GeeksMint.com, UbuntuMint.com, and the premium learning hub Pro.Tecmint.com.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

25 Comments

Leave a Reply
  1. Hi,

    I have installed Unison on my Fedora Linux 43 (Workstation Edition Prerelease) desktop. I’m trying to sync the files in my Downloads folder to my external SSD drive, but I’m getting the following error:

    jq@fedora:~$ unison ~/home/jq/Downloads ~/Backup/run/media/jq/128 WESTERN
    Usage: unison [options]
        or unison root1 root2 [options]
        or unison profilename [options]
    
    For a list of options, type "unison -help".
    For a tutorial on basic usage, type "unison -doc tutorial".
    For other documentation, type "unison -doc topics".
    To start interactive profile selection, type "unison -i".
    
    Profile '/home/jq/home/jq/Downloads' does not exist (looking for file /home/jq/.unison//home/jq/home/jq/Downloads.prf)
    jq@fedora:~$
    

    I’d really appreciate any help in figuring out what I’m doing wrong.

    Thanks,
    jq

    Reply
    • @JQ,

      Looks like the issue is with the paths you’re using in your Unison command. You don’t need to include /home/jq twice — Unison is interpreting that as a profile name instead of a folder.

      Try this command instead:

      unison ~/Downloads /run/media/jq/128\ WESTERN
      

      A few quick notes:

      The backslash (\) before the space in 128 WESTERN escapes the space so the system reads it correctly.

      You don’t need the ~/home/jq/ prefix — just ~/Downloads works fine.

      Make sure both directories actually exist and your external SSD is mounted.

      If this runs without errors, Unison should start syncing your Downloads folder to the SSD.

      Hope that helps!

      Reply
      • Hi Ravi,

        The following command works fine:

        unison ~/Downloads /run/media/jq/128\ WESTERN
        

        However, when I try to automate the job by creating a work profile, I encounter an error. Details are as follows:

        Profile (work.prf):

        root = /home/jq/Downloads
        root = /run/media/jq/128\ WESTERN
        
        auto = true
        batch = true
        prefer = newer
        

        When I run the command:

        jq@fedora:~$ unison work
        

        I get the following output:

        Unison 2.53.7 (ocaml 5.3.0): Contacting server...
        Looking for changes
        Reconciling changes
        new dir  ---->              
        
        1 items will be synced, 0 skipped
        45.9 MiB to be synced from Downloads to 128\ WESTERN
        0 B to be synced from 128\ WESTERN to Downloads
        Propagating updates
        Unison 2.53.7 (ocaml 5.3.0) started propagating changes at 09:14:51.85 on 16 Oct 2025
        [BGN] Copying from /home/jq/Downloads to /run/media/jq/128\ WESTERN
        Failed []: Error in creating directory:
        Permission denied [mkdir(/run/media/jq/.unison.128\ WESTERN.823146198a581844c627fe0871e557fe.unison.tmp)]
        Unison 2.53.7 (ocaml 5.3.0) finished propagating changes at 09:14:51.85 on 16 Oct 2025, 0.000 s
        Saving synchronizer state
        Synchronization incomplete at 09:14:51 (0 items transferred, 0 skipped, 1 failed)
          failed: 
        jq@fedora:~$
        

        I’d appreciate your help in resolving this.

        Thanks,

        Reply
        • @JQ,

          Thanks for sharing the details. From the error message, it looks like Unison is trying to create a temporary directory on /run/media/jq/128 WESTERN, but it doesn’t have permission to do so.

          A few things to check:

          1. Make sure your user (jq) has write permissions on the mount point /run/media/jq/128 WESTERN. You can test this by trying to create a folder manually:

          mkdir /run/media/jq/128\ WESTERN/test
          

          If this fails, it’s a permissions issue.

          2. If it’s a removable drive or a mounted partition, ensure it’s mounted with write permissions (sometimes drives are mounted read-only by default).

          3. You might also want to remove the backslash from the profile path and quote the path instead:

          root = "/run/media/jq/128 WESTERN"
          

          Unison handles spaces better with quotes in profile files.

          Try these steps and see if it resolves the issue.

          Reply
          • Dear Ravi Saive,

            This solved the problem:

            root = "/run/media/jq/128 WESTERN"
            

            But what if I want to sync to another SSD? There are two SSDs in the external case, how should I configure that?

            Here is my current work.prf:

            root = /home/jq/Downloads
            root = "/run/media/jq/128 WESTERN"
            
            auto = true
            batch = true
            prefer = newer
            

            I have another SSD mounted at /run/media/jq/128 KINGSTO in the same external case. How do I add it to work.prf?

            Thanks.

          • @JQ,

            Hi,

            Glad to hear the first part worked!

            For your second SSD, you can simply add another root entry in the work.prf file. Unison allows multiple roots, but each pair must refer to one sync job. Meaning: each work.prf can only define two roots at a time.

            So you’ll need a separate profile for the second SSD.

            For example, keep your existing work.prf as-is, then create another profile like work-kingsto.prf:

            root = /home/jq/Downloads
            root = "/run/media/jq/128 KINGSTO"
            
            auto = true
            batch = true
            prefer = newer
            

            Now you’ll run it like:

            unison work-kingsto
            

            This keeps both sync setups clean and avoids conflicts.

  2. I have been using unison GTK for years to keep the desktop and laptop in sync via a usb stick and it has never once failed to work! Marvelous bit of software.

    Reply
  3. Comparing Unison to rsync is OK, but why not compare it Syncthing, too? What’s advantage of Unison as compared o Synchthing?

    Reply
    • @Svashtar,

      Unison and Syncthing both handle two-way file sync, but they’re quite different in how they work:

      • Unison is more like a manual, deterministic sync tool, which scans both sides, shows you the changes, and lets you confirm or resolve conflicts before syncing.
      • Syncthing runs continuously in the background, syncing changes automatically over the network. It’s awesome for real-time, peer-to-peer sync, but you get less manual control over exactly when and how things sync.

      So, Unison is usually preferred for precise, predictable syncing (especially over SSH), while Syncthing shines for always-on, real-time sync across multiple devices.

      Reply
  4. To further elaborate on Ulath’s answer, Unison provides 2-way synchronisation. With rsync you have a source and a destination. You can make the destination look like the source but not the other way round. Conflicts can occur if you made changes on both sides but Unison has a variety of ways of dealing with these. I have a central server with 3 client machines that all sync slightly different datasets but there are some overlaps and Unison handles it very well. I take this over RAID any day. Much more portable and reliable.

    Reply
    • Thanks @PhiIT for such a nice explanation. I have quoted your comment at a few places where people were asking the difference between rsync and Unison.

      Keep connected!

      Reply
  5. i am using this for years without any breakage, data loss, etc. it is a very efficient and professional tool.

    @joe: it tracks the changes on both sides, such that you know if a file was deleted on the one side or created on the other.

    Reply
  6. Hi Avishek.
    How are you friend?
    I read your article about Unison.
    If I understood, the Unison do the same that rsync. So, my question is, what the advantage of the Unison about Rsync?

    Regards
    Daniel Noberto

    Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.