Bootstrap FreeKB - Linux Commands - rsync (remote copy)
Linux Commands - rsync (remote copy)

Updated:   |  Linux Commands articles

On a Linux System, the most popular ways to transfer a file from one Linux system to another Linux system are:

For example, scp or rsync could be used to transfer example.jpg from Machine 1 to Machine 2, or vice versa.

 

The Secure FTP (SFTP) command can be used to securely transfer files between Mac, Linux and Windows systems.


Copy local file

The rsync command with the -a or --archive flag can be used to copy the files in /tmp/dir1 to /tmp/dir2. This is very similar to using the copy command. However, rsync contains an algorithm that minimizes the amount of data copied by only moving the portions of files that have changed, which can result in reduced copy time when copying a large amount of data.

rsync --archive /tmp/dir1/ /tmp/dir2

 


download / pull / GET

In this example, the /tmp/foo directory on server2 will be copied to /tmp/foo on server1. This would be a download / pull / GET operation.

[john.doe@server1 ~]# rsync --archive john.doe@server2:/tmp/foo /tmp

 


upload / push / PUT

In this example, the /tmp/foo directory on server2 will be copied to /tmp/foo on server1. This would be a upload / push / PUT operation.

[john.doe@server1 ~]# rsync --archive /tmp/foo john.doe@server2:/tmp/foo

 


If you get Host key verification failed, the -e or --rsh option can be used. Check out my article on SSH strict host key checking.

[john.doe@server1 ~]# rsync --rsh "-o StrictHostKeyChecking=no" --archive john.doe@server2:/tmp/foo /tmp

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter c6d835 in the box below so that we can be sure you are a human.