May 20, 2022

How to transfer files/folder from one Linux server to another

Suppose you want to backup or transfer files from one remote server to another you can do it simply by using scp. Let me brief you about SCP.

SCP stands for secure copy (remote file copy program).

scp copies files between hosts on a network. It uses ssh(1) for data transfer, and uses the same authentication and provides the same security as ssh(1). scp will ask for passwords or passphrases if they are needed for authentication.


File names may contain a user and host specification to indicate that the file is to be copied to/from that host. Local file names can be made explicit using absolute or relative pathnames to avoid scp treating file names containing ‘:’ as host specifiers. Copies between two remote hosts are also permitted.

Enough of theory stuff, let’s see the example:

Suppose you want to transfer files/folder from to Therefore first login to the server and run the following command as follows:-

scp -r [email protected]:/var/www/ /var/www/html/


-r = Recursively copy entire directories. Note that scp follows sym‐bolic links encountered in the tree traversal.

root = User of that machine. = Ip of the server where the data exists.

/var/www/ = File that resides on server.(from where u will transfer)

/var/www/html = Directory of server where the files will be copied.

For the server which doesn’t have the default port 22 run the following command:

scp -r -P1234 [email protected]:/var/www/ /var/www/html/

Done Enjoy!!😎

Vedant Singh

Linux System Administrator | Entrepreneur | Founder Techmion. I have started my career as a Linux system Administrator after that quit my job to start something new that excites me and started a Tech Company in order to provide the best technology to my clients. My Company website link: For Bulk, SMS-Marketing follows the link :

View all posts by Vedant Singh →

Leave a Reply

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


Ad Blocker Detected!

We've noticed that you are using an ad blocker. Advertising helps fund our server cost and keep it truly independent. It helps to build our content creator team. So please disable your ad blocker, and help us to keep providing you with free- great content - for free. Thank you for your support.