How to transfer files from one linux server to another
In a multi-server Linux environment, you’d want to transfer several files at once from one Linux server to another. Depending on the number and type of files involved, there are several ways you can carry out the operation.
Transferring a single file from one Linux server to another:
For a single file:
In this case, you can make use of the “SCP” command. It is basically a “push” / “pull” command with a built-in SSH command that basically pushes your file from its origin to the destination server with little effort.
Open the tool ‘PuTTY‘. It is a terminal emulator application. It acts as a client for computing protocols such as SSH, Telnet, rlogin, and TCP. It can be easily downloaded for free directly from Google.
Type the file transfer command in the following convention.
It reads as “copy file” into “target_folder” at “target_host” using “user account“.
So the file gets copied to another system, into the mentioned user id. This file can be pulled from another system with the command as shown below:
[email protected]_host:target_folder file.
For copying an entire directory:
Make use of the “SCP” command here as well. Add the -r switch so that the copy function can act in a loop till all files get copied. The command would read as shown below.
scp -r [email protected]_host
The complete directory gets copied to another system.
Copying multiple files from one Linux server to another
When the number of files involved are more than one, it gets sort of troublesome to transfer them one by one. A better way to achieve the same intended result is to transfer the entire directory or a bunch of files at once.
This can be done using the ‘tar’ command. ‘Tar’ creates a collection of files that act as one unit and can be transferred the same way we did in point 1. This singular file thus created follows the same rule of commands as other files.
Does your server slow down while transferring files?
Bring home a more robust and powerful Linux server powered by intel Xeon chips featuring up to 32 cores and 1 GBPS bandwidth.