scp copy directory Explained¶
Introduction¶
This article explains a common scp usage that administrators and learners often need to understand clearly.
What This Command Means¶
The command performs this specific task with scp:
scp -r project admin@server:/srv/
Breaking Down the Command¶
scpis the command being run.- The options or arguments decide the behavior.
- The final value is the target, such as a file, process, service, package, host, URL, or directory.
Practical Examples¶
scp -r project admin@server:/srv/
scp admin@server:/var/log/app.log .
ssh admin@server ls -l /tmp/file.txt
Example output:
-rw-r--r-- 1 admin admin 1200 May 30 10:00 /tmp/file.txt
When to Use It¶
Use scp for simple one-time file transfers over SSH. For repeated syncs or large directory trees, rsync is often a better tool.
Common Mistakes¶
- Using lowercase
-pwhen you meant uppercase-Pfor port. - Forgetting
-rwhen copying a directory. - Putting the colon in the wrong place in a remote path.
Safer Alternatives¶
Inspect before changing state when possible:
ssh admin@server ls -l /tmp/file.txt
For wider changes, test on a small target before using the command broadly.
Related Guides¶
Summary¶
Understanding scp copy directory is about knowing what each part does and checking the final state after running it.