CloudsArk
Commands Linux

scp copy directory Explained

Understand what scp copy directory means, how to break it down, and when to use it safely.

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

  • scp is 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 -p when you meant uppercase -P for port.
  • Forgetting -r when 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.

Summary

Understanding scp copy directory is about knowing what each part does and checking the final state after running it.