Thursday 12 March 2020

Top 10 Examples of scp command in Linux

The SCP (Secure Copy) command in Linux is used to securely transfer files between two hosts over a network. 

Here are the top 10 SCP commands with a brief explanation and code examples:


1.Copy a file from a local host to a remote host:

scp file.txt user@remotehost:/path/to/destination

2.Copy a file from a remote host to a local host:

scp user@remotehost:/path/to/file.txt /path/to/destination


3.Copy a directory from a local host to a remote host:

scp -r directory user@remotehost:/path/to/destination


4.Copy a directory from a remote host to a local host:

scp -r user@remotehost:/path/to/directory /path/to/destination


5.Copy multiple files from a local host to a remote host:

scp file1.txt file2.txt user@remotehost:/path/to/destination


6.Copy files from a remote host to multiple local hosts:

scp user@remotehost:/path/to/file1.txt /path/to/destination1 scp user@remotehost:/path/to/file2.txt /path/to/destination2


7.Use a specific port for the SCP transfer:

scp -P 2222 file.txt user@remotehost:/path/to/destination


8.Show the progress of the SCP transfer:

scp -r file.txt user@remotehost:/path/to/destination --progress


9.Copy files with compression to reduce transfer time:

scp -C file.txt user@remotehost:/path/to/destination


10.Copy files with verbose output to see detailed information about the transfer:

scp -v file.txt user@remotehost:/path/to/destination


Note: In all of these commands, replace file.txt, directory, user, remotehost, and /path/to/destination with the appropriate values for your use case.

Labels: , ,

0 Comments:

Post a Comment

Note: only a member of this blog may post a comment.

<< Home