For individuals with more than one computer, trying to keep files in sync between them can be an exercise in frustration. Typically, tools such as rsync are used to synchronize files from one system to another, but the problem is that it's a one-way sync.
With a program called Unison, you can take advantage of the same synchronization features of rsync, but in more than one direction. With Unison, the files changed on your laptop will get synchronized with those on your desktop, and vice versa.
Unison is also cross-platform, which means you can synchronize your Linux desktop with your Windows desktop and OS X laptop. It also can take advantage of SSH, meaning you can synchronize files from home while you're at work or at a coffee shop on a public Wi-Fi connection.
That being said, Unison insists on having the same version on each system. If every system runs the same version of Mandriva or Ubuntu, it would be feasible to install a vendor-provided binary package. The current stable version is 2.13.16, and binary packages are available for all platforms, including Linux. If you have multiple Linux systems running, for example, one Mandriva and one Ubuntu, instead of installing from the vendor's packages, you may opt to download a binary from the Web site instead to ensure every OS is running the same version.
To begin, once Unison is installed, you can start it in GUI mode by executing unison. To operate in text-mode, use unison -ui text. To become familiar with Unison, test it locally; Unison can synchronize directories on the same system just as well as synchronizing directories with remote systems.
To begin, a simple test as follows is sufficient to demonstrate Unison:
$ cd ~/tmp/
$ mkdir one two
$ touch one/1 two/2
$ echo "3" >one/3
$ unison -ui text one two
Unison will give you a bit of information as to what it intends to do. You'll then see the following output at which point you will need to confirm what you want it to do:
Press return to continue.[<spc>] Reconciling changes
file ——> 1 [f] .
<—— file 2 [f]
file ——> 3 [f]
Proceed with propagating updates?  y
UNISON 2.13.16 started propagating changes at 08:30:32 on 06 Sep 2007
[BGN] Copying 1 from /home/user/tmp/one to /home/user/tmp/two
[END] Copying 1
[BGN] Copying 2 from /home/user/tmp/two to /home/user/tmp/one
[END] Copying 2
[BGN] Copying 3 from /home/user/tmp/one to /home/user/tmp/two
[END] Copying 3
UNISON 2.13.16 finished propagating changes at 08:30:32 on 06 Sep 2007
Saving synchronizer state
Synchronization complete (3 items transferred, 0 skipped, 0 failures)
As you can see, Unison tells you which way a file will be transferred, and you can change this on a per-file basis. For instance, the [f] noted above tells Unison to follow its own recommendation, which it displays but you can change this by clicking ? to get a list of options. You can tell Unison to ignore files, show differences, change the propagation direction, and more.
To transfer to and from other systems, make sure both Unison and SSH are installed on each system. Then simply call Unison using SSH:
$ unison -ui text one ssh://somehost/home/user/two
This will synchronize the directory one/ with the remote directory /home/user/two on the remote system somehost via SSH.
Unison also has support for profiles, which allow you to create configuration files that can set preferences on different directories and files. Comprehensive documentation on profiles is available on the Web site.
All in all, Unison can be extremely useful and quite powerful. It doesn't take the blind-sync approach by default, but allows you to determine what files to sync, if any, and in what direction. Using profiles, you can largely automate things to suit your situation.
Delivered each Tuesday, TechRepublic's free Linux NetNote provides tips, articles, and other resources to help you hone your Linux skills. Automatically sign up today!
Vincent Danen works on the Red Hat Security Response Team and lives in Canada. He has been writing about and developing on Linux for over 10 years and is a veteran Mac user.