Linux Commands | Network | scp Copy Files Between Servers

scp Command

The scp command is used in Linux to copy files between servers.

scp Usage

scp {file-to-copy} {server-user-id}@{server-address}:{copy-path-on-server}

Notes

  • You must know the server ID and password.
  • Be sure to add : (colon) before the copy path on the server.
  • The server copy path must be writable by the server user account you entered.

scp Command Examples

Example: Copy a File

Copy a local file named test.txt to the /home/devkuma directory on the server.

scp ./test.txt devkuma@192.168.0.10:/home/devkuma

Example: Copy a Directory

Copy a local directory named test_dir to the /home/devkuma directory on the server.

scp -r ./test_dir devkuma@192.168.0.10:/home/devkuma

The difference from copying a file is that the -r option is added.