Linux

SCP Command Examples In Linux [ Beginner’s Guide ]

SCP Command Examples In Linux [ Beginner's Guide ]

Insight: SCP Command Examples In Linux [ Beginner’s Guide ]

SCP command is used to securely copy files or folders in Linux. It is used to transfer between remote hosts. It won’t use FTP session during the transfer process. It uses SSH to move data.

Syntax:

scp [options] [email protected]_host:directory1/omgfoss.txt [email protected]_host:directory2/filename2

[email protected]_host:directory1/omgfoss.txt is the location of the source file. username1 is the name of an user account on the host computer. source_host is the hostname of the source destination. directory1 is the directory where the file omgfoss.txt is located.

The location to which the source file will be copied is: [email protected]_host:directory2/omgfoss.txt
 

SCP Command Examples In Linux

Run the following command in terminal to run to copy file from local host to remote host:

$ scp omgfoss.txt [email protected]_host:/remote/directory/

Run the following command to copy file from a remote host to local host :

$ scp [email protected]_host:omgfoss.txt /local/directory/

Run the following command to copy directory from a remote host to local host :

$ scp -r [email protected]_host:/remote/directory/  /local/directory/

Run the following command to copy directory from local host to a remote host:

$ scp -r /local/directory/ [email protected]:/remote/directory/

Run the following command to opy file from remote host to remote host:

$ scp [email protected]_host:/remote/directory/file.txt [email protected]:/remote/directory/

Important Note: scp command will replace the contents of the target file while copying a source file to a target file which already exists.

Let us know if there is any error in this article.

 



READ THIS ALSO  How To Clean Virus By Command Line In Ubuntu | Linux Antivirus

Subscribe To Our Newsletter.

Join our mailing list to receive the latest linux tutorials, tips & tricks, freebies,news and updates from our team.

You have Successfully Subscribed!