Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the hueman domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/CloudIngenium.com/htdocs/wp-includes/functions.php on line 6114
HowTo: Copy Files Over The Network using the Ubuntu Command Line – Knowledge eXchange

HowTo: Copy Files Over The Network using the Ubuntu Command Line

HowTo: Copy Files Over The Network using the Ubuntu Command Line

As I continued to struggle in this GUI-less word, the need for transferring files over the network arose. I needed to get a lot of files from one place to another and I just simply didn’t know how to do it. Linux obviously offers a number of alternatives for transferring / copying files over the network and you can also configured shared folders over the network. For those who are new to Linux/Ubuntu/Debian/etc. here are a few ways you can accomplish a file transfer over ssh:

I. SCP

I tend to use Secure Copy most of the time as it was the first tool I was introduced to. The syntax is rather simple and its use is very straighforward. If you want you can find the manual of SCP with its syntax here: SCP.

To use SCP simply do the following:

type scp followed by the -r directive to indicate recursive (sub folders, etc.). After that you need to type the server and the username used to connect to it in the following format UserName@ServerAddress. Immediately after that you will put a colon and follow it by the destination route.

For example, if you wanted to copy all your conf folders (think that you have three folders with the names of: conf.sites, conf.common, and conf.ssl)

scp -r /etc/nginx/conf.* SuperUser@CloudIngeniumServer.CloudIngenium.com:/etc/nginx

That command will copy all the folders/files in the current directory that match the pattern conf.* to /etc/nginx in the target server. The result in this case would be three folders with all their contents copied over.

II. RSync

RSync is a new tool I found out about which has a few added benefits and it is maintained by the guys at Samba. You can find a copy of the manual here for your perusal: RSync. Rsync has the advantage that out of the box it will copy not only the file but the file permissions among other things (ownership, time stamps, etc.) This is done by using the -a parameter which indicates archive.

Using Rsync is not much different than using SCP. Simply follow this basic example:

Suppose you want to copy the directory ~/myDirectory from user UserName on machine ServerName to your local machine and in the current directory. For this you would run the following command:

rsync -avzn UserName@ServerName:~/myDirectory .

Note that we used the -n parameter which will make rsync to only output the actions it will perform without actually doing it. This is good for testing and making sure you’ll get the desired outcome. If you hare happy with it, simply remove the -n option and perform the file copy operation via ssh:

rsync -avz UserName@ServerName:~/myDirectory .

NOTE: For either method to work you need SSH to be working on both the client and the server machines.

Enhanced by Zemanta

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.