Tools
Sync two folders (bidirectional synchronization)
Install
sudo dnf install unisonInitial sync
unison /path/to/folderA /path/to/folderB -auto -batch- if folderA has context, folderB is empty —> folderB will be filled in folderA stuff
- if both folders have different files already, unison will merge them
-auto : Automatic Mode. Unison automatically resolve non-conflicting changes. If a file is new or unchanged in both locations, Unison will sync it without asking.
-batch : Fully Automatic Mode. this makes Unison completely non-interactive. It assumes the latest modified version wins and resolves all conflicts automatically.
If meeting permission issue: Then don’t sync permission
unison /path/to/folderA /path/to/folderB -auto -batch -perms 0Build connection
Sync every xx seconds
while true; do unison /path/to/folderA /path/to/folderB -auto -batch; sleep 5; done
This is a Bash infinite loop that repeatedly runs Unison every 5 seconds
do: marks the beginning of the loop bodydone: marks the end of the loop body
everything between
doanddoneruns once per loop iteration
sleep 5: pauses execution for 5 seconds before restarting the loop
this is only good for syncing across network drives (NFS, SSH etc)
Watch mode
(terminal open, stop when terminal window close)
Monitor file changes in real-time and sync only when necessary
unison /path/to/folderA /path/to/folderB -auto -batch -repeat watch-repeat watch: enables watch mode , detecting changes in real-time
Run as a Background Service
Instead of keeping a terminal open, create a systemd service:
sudo nano /etc/systemd/system/unison-sync.servicePaste:
[Unit]Description=Unison Sync ServiceAfter=network.target
[Service]ExecStart=/usr/bin/unison /home/j/projects/digital-debris/src /mnt/D/blog/digital-debris/src -auto -batch -repeat watch -silent -prefer newer -perms 0Restart=alwaysUser=jGroup=jWorkingDirectory=/home/j
[Install]WantedBy=multi-user.targetThen enable it:
sudo systemctl daemon-reload sudo systemctl restart unison-sync sudo systemctl enable —now unison-sync`
This makes Unison run in the background automatically.
check Unison status:
systemctl status unison-syncStop Unison if needed
sudo systemctl stop unison-syncDisable it permanently
sudo systemctl disable unison-syncBreak connection
If Unison is running in a loop, kill it:
For example : in while true —> execute pkill unison
Remove Synchronization Metadata:
rm -rf ~/.unison
Change background color (solid color) on Gnome
- launch dconf Editor —
dconf-editor - Go to
/org/gnome/desktop/background/ - if you have a picture: go to
picture-url, change Custom value tonone - if not, just change the color: go to
primary-color, changeCustom valueto desired one