Interview Q&A / Linux & Shell

IntermediateQuick answer1 min readUpdated 3 Oct 2026

What is the difference between scp and rsync for copying files over SSH?

SHORT ANSWER

Both copy over SSH. scp sends the whole file every time, while rsync compares source and destination and sends only the differences, can resume, and can preserve permissions and delete extras. Use scp for one-off copies and rsync for repeated syncs and large folders.

Explain it simply

Imagine sending a 500-page document to a friend who already has 498 of the pages. scp prints and couriers all 500 again. rsync checks first and sends only the 2 that changed.

scp report.pdf amit@server:/home/amit/ copies one file. scp -r folder/ amit@server:/backup/ copies a directory. -P 2222 sets the port (capital P, unlike ssh's lowercase -p).

rsync -avz folder/ amit@server:/backup/folder/:

  • -a archive: recursive and keeps permissions, times and links
  • -v verbose, -z compress in transit
  • --progress and -P show progress and allow resuming
  • --delete removes files from the destination that no longer exist at the source (use with care; try --dry-run first)

Trailing slashes matter in rsync: folder/ copies the contents, folder copies the folder itself.

Example

bash
scp -P 2222 notes.txt amit@203.0.113.10:/tmp/
rsync -avz --dry-run site/ amit@203.0.113.10:/var/www/site/
rsync -avzP site/ amit@203.0.113.10:/var/www/site/

What to say in the interview

"scp copies everything each time; rsync transfers only differences and can resume, so I use rsync -avz for backups and deployments and scp for a quick single file. I run rsync with --dry-run before using --delete."

Common mistakes

  • Forgetting the trailing slash on the rsync source and creating a nested folder.

#linux#networking#scp#rsync

Related questions

Practise more Linux & Shell questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Linux & Shell quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.