Tuesday, October 2, 2018

scp command examples

scp Command

1) Transfer single file to remote host 
scp abc.txt username@remote_ip:/remote_path/

2) Transfer multiple files to remote host 
scp *.txt username@remote_ip:/remote_path/
                OR
scp /path/*.txt username@remote_ip:/remote_path/               
                OR
scp /path/* username@remote_ip:/remote_path/
                OR
scp abc.txt abc1.txt abc2.txt username@remote_ip:/remote_path/               

3) Copy single file from remote to local 
scp username@remote_ip:/remote_path/abc.txt .
                
4) Copy multiple files from remote to local 
scp username@remote_ip:/remote_path/*.txt .

5) Copy a directory to remote host 
scp -r abc username@remote_ip:/remote_path/

6) Transfer single file to remote host in silent mode 
scp -q /abc/xyz.txt username@remote_ip:/remote_path/

Note:- "-q" option is for silent mode and progress of command and error will not be displayed on monitor

7) Transfer single file to remote host via specific port 
scp -P 922 /abc/xyz.txt username@remote_ip:/remote_path/

Note:- If port is not default then Port Number need to mentioned by "-P" option

8) Transfer faster by "-C" option for big file to remote host
scp -C -P 922 /abc/xyz.txt username@remote_ip:/remote_path/

Note:-"-C" option will compress files on the go. Compression is happen in the network only.
      When the file is arrived to the destination server, it will return into the original size.
     
9) Transfer files from one remote host to another remote host
scp username@remote_host1:/remote1_path/ username@remote_host2:/remote2_path/

10) Transfer a file with preserve file attributes
scp -p test.txt username@remote_ip:/remote_path/

No comments:

Post a Comment

Remove CTRL-M characters from a file in UNIX

 We can remove ^M by below methods 1st Method - Using sed command Type below command:    sed -e "s/^M//" filename > newfilena...