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.






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
@JQ,
Looks like the issue is with the paths you’re using in your Unison command. You don’t need to include
/home/jqtwice — Unison is interpreting that as a profile name instead of a folder.Try this command instead:
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~/Downloadsworks 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!
Hi Ravi,
The following command works fine:
However, when I try to automate the job by creating a work profile, I encounter an error. Details are as follows:
Profile (
work.prf):When I run the command:
I get the following output:
I’d appreciate your help in resolving this.
Thanks,
@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: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:
Unison handles spaces better with quotes in profile files.
Try these steps and see if it resolves the issue.
Dear Ravi Saive,
This solved the problem:
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:I have another SSD mounted at
/run/media/jq/128 KINGSTOin 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.prffile. 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.prfas-is, then create another profile likework-kingsto.prf:Now you’ll run it like:
This keeps both sync setups clean and avoids conflicts.
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.
Comparing Unison to rsync is OK, but why not compare it Syncthing, too? What’s advantage of Unison as compared o Synchthing?
@Svashtar,
Unison and Syncthing both handle two-way file sync, but they’re quite different in how they work:
So, Unison is usually preferred for precise, predictable syncing (especially over SSH), while Syncthing shines for always-on, real-time sync across multiple devices.
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.
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!
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.
Thanks @Ulath for your feedback.
Keep connected for more such posts.
Hello
I need to install unison on CentOS 7. I installed EPEL, it is enabled but it doesn’t find unison in the repo.
I also looked at the repo content here:
http://dl.fedoraproject.org/pub/epel/beta/7/x86_64/
But there is no unison package. Perhaps it wasn’t compiled yet for CentOS 7?
Andrei, seems Unison is not yet made available under CentOS 7 default repo, but you can install it from source.
yum install ocaml ocaml-camlp4-devel ctags ctags-etags
cd ~
wget -> take the link from here http://www.seas.upenn.edu/~bcpierce/unison/download/releases/stable/
For example:
wget http://www.seas.upenn.edu/~bcpierce/unison//download/releases/stable/unison-2.48.3.tar.gz
Extract the file for example:
tar xvfz unison-2.48.3.tar.gz
Enter to the created directory:
cd unison-2.48.3.tar.gz
make
sudo cp -v unison /usr/local/sbin/
sudo cp -v unison /usr/bin
cd ~
rm -fr unison*
Thanks to your post I was finally able to get Unison working again. I’ve been using it for years but it broke recently after upgrading Cygwin. I fixed that but then needed to install Unison 2.48.3 on the remote server. Your instructions worked up until “sudo cp -v unison /usr/local/sbin/”. For some reason I was getting an error about dangling symlinks and it seemed that a symlink was being created and not the executable being copied. I followed the accepted answer here http://goo.gl/CjQXia and it finally worked.
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
Thanks Daniel Noberto,
I am fine hope you are fine as well.
Sorry for late reply.
Rsync and Unison are very different. Look at the comment of PhiIT here: https://www.tecmint.com/file-synchronization-in-linux-using-unison/comment-page-1/#comment-639635
What does this offer over just rsync and a gui?
You should go through the comment of PhiIT. He nicely explained the difference between rsync and Unison. Unison is not rsync+gui. Here you may like to go through: https://www.tecmint.com/file-synchronization-in-linux-using-unison/comment-page-1/#comment-639635
Thanks for this wonderful Tool…!
Welcome @abilash,
Hope you are enjoying the post here on Tecmint.
I enjoy you articles.
FYI
GNU Public License
Thanks @scott for your feedback.
Keep connected to Tecmint.