SCP & Rsync Cheatsheet - File Transfer
Moving files between servers, scp is simple but always copies everything and restarts on interruption; rsync does incremental transfer and can resume, saving bandwidth and suiting ongoing sync. This table pairs their common flags so you pick the right tool for one-off copies versus recurring sync.
scp Basics 8
scp file user@host:/pathUpload a file to remote
scp user@host:/path/file .Download a file from remote
scp -r dir user@host:/pathRecursively upload a directory
scp -P 2222 file user@host:/pathSpecify a port
scp -i ~/.ssh/id_rsa file user@host:/pathSpecify a private key
scp -C file user@host:/pathEnable compression
scp -q file user@host:/pathQuiet mode
scp -v file user@host:/pathVerbose output
rsync Basics 8
rsync file user@host:/pathSync a file to remote
rsync user@host:/path/file .Sync a file from remote
rsync -r dir user@host:/pathRecursively sync a directory
rsync -a dir user@host:/pathArchive mode (preserves perms, timestamps...)
rsync -av dir user@host:/pathArchive mode with verbose output
rsync -az dir user@host:/pathArchive mode with compression
rsync -e "ssh -p 2222" file user@host:/pathSpecify the SSH port
rsync -e "ssh -i key" file user@host:/pathSpecify the SSH key
rsync Incremental 6
rsync -av --delete src/ user@host:/path/Sync and delete extra files on the target
rsync -av --update src/ user@host:/path/Sync only newer files
rsync -av --ignore-existing src/ user@host:/path/Skip files already present
rsync -av --dry-run src/ user@host:/path/Simulate (no actual transfer)
rsync -av --progress src/ user@host:/path/Show transfer progress
rsync -av --partial src/ user@host:/path/Keep partial files (resume)
rsync Filtering 5
rsync -av --include="*.txt" src/ dest/Sync only a given type
rsync -av --exclude="*.tmp" src/ dest/Exclude a given type
rsync -av --exclude=".git" --exclude="node_modules" src/ dest/Exclude multiple directories
rsync -av --exclude-from=exclude.txt src/ dest/Read exclude rules from a file
rsync -av --filter="+ *.txt" --filter="- *" src/ dest/Use filter rules
rsync Advanced 6
rsync -av --compress src/ dest/Compress during transfer
rsync -av --checksum src/ dest/Compare files by checksum
rsync -av --size-only src/ dest/Compare by size only
rsync -av --modify-window=1 src/ dest/Modification-time window (FAT filesystems)
rsync -av --log-file=rsync.log src/ dest/Write a log
rsync -av --stats src/ dest/Show statistics
Common Patterns 6
rsync -avz --progress --partial file user@host:/pathResume a large file
rsync -avz --delete src/ user@host:/path/Mirror a directory
rsync -avz --exclude=".git" --exclude="node_modules" src/ dest/Sync code (skip deps)
rsync -avz --backup --backup-dir=backup src/ dest/Sync and back up changed files
rsync -avz --max-size=100m src/ dest/Cap transferred file size
rsync -avz --bwlimit=1000 src/ dest/Limit bandwidth (KB/s)
Tips
- scp suits simple transfers; rsync suits directory sync and incremental transfer.
- rsync --delete removes extra target files; confirm the target has nothing important first.
- With rsync, src/ syncs the directory's contents, src syncs the directory itself.
Official References
Each command links to its official documentation below, so you can verify the latest usage and read deeper.
Maintained by LaoHand
Publicly updated on Jul 21, 2026, continuously proofread against official docs.
Contact Us
Wrong command or description? Send us corrections, business inquiries or product feedback by email.
Contact Us