Contributor
Kyle
October 23
Edit

SCP command to transfer files/folders in Linux

Basic syntax of SCP

scp source_file_name username@destination_host:destination_folder

Example:

user@localhost ~/Documents $ scp -v user.name@212.x.x.x:.

Copy a Directory Recursively using SCP

I often need to quickly copy a directory from one Linux machine to another. An easy command to accomplish the task is the SCP (Secure Copy) command. Here's the general format of a recursive copy.

scp -r [/local/path/] [user@host]:[/remote/path]

The -r switch causes scp to copy recursively. It copies all files and directories under the one specified. 

You can use the * wildcard as your local path to copy the current directory and everything below it.

rsync Alternative

You can also use the rsync command to copy files in a similar manner. rsync has a few more options and the advantage that it only copies changed files.

rsync -a [/local/path/] [user@host]:[remote/path/]

Send us a message. We will reply as soon as we can.