3.7 Transferring files

FTP with a graphic user interface such as FileZilla is often the best choice for transferring files to a remote computer but sometimes for a single file or folder, scp is a good alternative. Use this command to send a zipped folder from the current folder to a folder on the remote computer.

scp myfolder.zip jimmy@vdsbasic.xyz:/home/jimmy/transfer

Once it is in place we can unzip it:

unzip myfolder.zip

It will create a directory structure but the tree will be under ~/transfer. We need to move it while preserving the file structure. The easiest way is to use rsync with the r ( recursive function)

First:
sudo mkdir /var/www/html/myfolder
rsync -r ~/transfer/ /var/www/html/myfolder

The command copies all the files to the new directory. You could also use the move command here to preserve the file structure. rsync will leave the original files in place but move will not.

The rsync command is a very useful one and can also be used to transfer folders from one computer to another. This page goes into detail for this command. This page covers scp.

Becoming familiar with these commands is very useful when working in Linux. Don't worry about remembering the syntax - I often google and copy. What is important is knowing which command to use.

No comments:

Post a Comment

Introduction to Linux Command Line

SSH is the way you will connect to your Linux server. You will need to understand the basics of the Linux Command Line.