The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Use cp for a one-time copy on the same machine, scp for a straightforward directory transfer over SSH, and rsync when you will repeat the transfer, synchronize a tree, exclude files, or avoid resending unchanged data. The commands differ most in where they work, what metadata they preserve, and how they place the source directory at the destination.
Choose the command that matches the job
| Command | Where it copies | Best fit | Recursive directory syntax | Preservation and repeat transfers |
|---|---|---|---|---|
cp |
Local filesystem only | One-time local copy | cp -R, cp -r, or cp -a |
-a is the archive form when preservation is wanted; it has no network or delta-transfer feature |
scp |
Between hosts over SSH | Simple remote upload or download | scp -r |
-p preserves modification times, access times, and mode bits; repeated runs transfer through the SSH copy operation rather than a documented delta algorithm |
rsync |
Local or remote | Synchronization, backups, mirroring, exclusions, and repeated transfers | rsync -r (or the commonly used archive form, -a) |
Its delta-transfer algorithm sends only differences; it can use a remote shell or an rsync daemon |
GNU Coreutils documents that cp does not copy directories by default. OpenSSH’s scp recursively copies a directory with -r, while rsync uses recursive mode for directory trees.
Copy a directory on the same Linux machine with cp
Use the archive form when the copy should retain filesystem metadata:
cp -a source_dir destination_dir/
This places source_dir inside destination_dir. If destination layout matters, ensure the destination path exists or choose the intended new pathname explicitly.
#1 Best Overall
Use recursive copy without archive preservation
cp -r source_dir destination_dir/
-R is another recursive spelling. Choose -r or -R when copying the directory tree is sufficient and archive-style preservation is not required.
Common cp mistake
Running cp source_dir destination_dir/ without a recursive option fails because directories are not copied by default. Add -a, -r, or -R rather than treating the directory like a single regular file.
Copy a directory to another host with scp
Push a local directory to a remote host
scp -r source_dir user@host:/remote/path/
This opens an SSH transfer and recursively sends the directory tree. Replace user, host, and /remote/path/ with the account, system name or address, and destination path you can access.
Preserve times and mode bits
scp -r -p source_dir user@host:/remote/path/
The -p option preserves modification times, access times, and mode bits. Use it when those attributes are part of the copy requirement; it does not turn scp into a synchronization tool.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Pull a directory from a remote host
scp -r user@host:/remote/path/source_dir ./destination/
The remote path appears before the local destination. The current OpenSSH implementation uses SFTP for the transfer while retaining the familiar scp command interface.
Synchronize directories with rsync
rsync works both between local paths and across hosts. Its delta-transfer algorithm compares the source and destination and sends only differences, which is useful after the first copy. It can operate through a remote shell or an rsync daemon.
Rank #4
Push directory contents to a remote host
rsync -a source_dir/ user@host:/remote/path/
Here, the trailing slash on source_dir/ means “copy the contents of this directory.” Files and subdirectories from inside source_dir are placed directly under /remote/path/.
Pull directory contents from a remote host
rsync -a user@host:/remote/path/source_dir/ ./destination/
The same trailing-slash rule applies to a remote source: the contents of source_dir go into ./destination/.
Best Value
Put the source directory itself below the destination
rsync -a source_dir user@host:/remote/path/
Without the slash, rsync copies the directory named source_dir as an entry below /remote/path/, producing /remote/path/source_dir (with its contents). This single character is the most important rsync destination-layout distinction.
Use recursive mode explicitly
rsync -r source_dir/ user@host:/remote/path/
The -r option tells rsync to copy directories recursively. The -a form used in the examples is the usual choice when an archive-style directory transfer is wanted.
Quick Recap
How destination layout differs
| Command | Source written as | Result under destination |
|---|---|---|
cp -a source_dir destination_dir/ |
Directory name | destination_dir/source_dir |
scp -r source_dir user@host:/remote/path/ |
Directory name | The remote destination contains source_dir |
rsync -a source_dir/ user@host:/remote/path/ |
Directory contents (trailing slash) | Contents go directly into /remote/path/ |
rsync -a source_dir user@host:/remote/path/ |
Directory itself (no trailing slash) | /remote/path/source_dir is created or updated |
Practical decision guide
- Choose
cpwhen both paths are on one machine and this is a local, one-time copy. Use-aif preservation matters. - Choose
scpwhen the source and destination are different hosts, SSH is available, and straightforward recursive copying is all you need. Add-pfor times and mode bits. - Choose
rsyncfor repeated synchronization, backups, mirrors, exclusions, or large trees where avoiding retransmission of unchanged data matters. Decide deliberately whether the source path ends in/.
Checks before running a directory copy
- Confirm the source path and whether it names a directory or its contents.
- Confirm that the destination account can write to the target path.
- For remote commands, verify the SSH host, username, and remote path.
- Decide whether metadata preservation is required before choosing
cp -a,scp -p, or an archive-style rsync command. - For rsync, inspect every source path for the trailing slash so the resulting directory layout is intentional.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




