Vol. I · No. 46The command line sectionSat, 10 Oct 2026
Linux · file management

rsync

copy only the differences

rsync synchronises one directory with another. It compares the two sides and sends only the files — and the parts of files — that differ, which makes a repeat run nearly instant. It works locally and, over SSH, between machines.

cp copies everything every time; rsync copies only what changed.

Transfers
Only differences
by size and modification time
Usual switches
-avh
archive, verbose, readable sizes
Remote
user@host:path
carried over SSH
Rehearse
-n
a dry run that changes nothing

At the terminal

Read the session first, then the notes: each numbered line in the output is answered by the note with the same number.

user@netflow — bashrsync
$ rsync -avh site/ backup/site/
1sending incremental file list
./
index.html
css/
css/style.css
 
2sent 6.31K bytes received 65 bytes 12.75K bytes/sec
total size is 6.03K speedup is 0.95
3$ rsync -avhn --delete site/ user@192.0.2.10:/var/www/site/
sending incremental file list
4deleting old.html
index.html
Illustrative session · names, sizes and dates are examples, and every address is from a documentation or private range
Reading the output

What the numbered lines are telling you

1
The files that needed sending

On a first run that is everything. The trailing slash on site/ means "the contents of site", not the directory itself.

2
The transfer summary

Run the same command again and "sent" drops to a few hundred bytes: nothing has changed, so nothing is copied.

3
A remote destination, rehearsed

user@host:path sends over SSH. -n makes this a dry run: it reports what would happen and changes nothing.

4
--delete removes extras

old.html exists on the server but not locally, so a real run would delete it there. This is why the dry run comes first.

Switches

A switch changes how the command behaves. These are the ones used day to day; man rsync lists the rest. Single-letter switches can usually be joined, so -l -a may be written -la.

-a
Archive: recursive, and keep permissions, times, owners and links.
-v
Verbose: list each file transferred.
-h
Human-readable sizes.
-n
Dry run: show what would be done, change nothing.
-z
Compress data during transfer — helps on a slow link.
-P
Show progress and keep partial files, so a transfer can resume.
--delete
Remove files from the destination that are not in the source.
--exclude=PATTERN
Skip files matching the pattern.

Variations worth knowing

The same tool, pointed at a narrower question. These four cover most of what it is reached for day to day.

rsync -avh --progress big.iso user@192.0.2.10:

Copies one large file to a remote home directory, showing progress.

rsync -avh --exclude ".git" project/ backup/

Leaves out anything matching a pattern.

rsync -avhP user@192.0.2.10:/var/log/app/ logs/

Pulls from a remote machine. -P keeps partial files so an interrupted copy can resume.

rsync -a --delete src/ dst/

Makes dst an exact mirror of src, removing anything extra.

In cybersecurity

With --delete, rsync is a command that removes files on another machine.

The trailing slash changes the meaning

"site/" copies the contents; "site" copies the directory. Combined with --delete, getting it wrong can empty the destination. Rehearse with -n.

It runs over SSH

The transfer is encrypted and authenticated by SSH. The old rsync:// daemon protocol is neither, and should not face the internet.

A mirror is not a backup

A mirror copies deletions and corruption faithfully. A backup needs older versions too — see --link-dest, or a real backup tool.

Protocols it shows

SSHTCP

Read alongside