Friday, December 25, 2015

Using scp command on Linux to copy Files and Directories

DBAs need to move files from one host to the other in Linux environment. In this article, I would explain how to use scp (secure copy) command to copy files or directories from one host to the other.
Currently I am on (MYDBSERVER is the hostname in this case) and I have a file /u01/oracle.tar on second host that I want to transfer to /u01 on my current host, On current host I am connected as user “salman” and “oracle” is the user on remote host that I will use to connect to remote host for this copy operation.
[salman@MYDBSERVER /] cd /u01
[salman@MYDBSERVER u01]$  scp oracle@ /u01/
The authenticity of host ' (' can't be established.
RSA key fingerprint is ce:dd:13:2d:ac:96:a1:cd:52:9e:f3:b4:03:ea:2d:25.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ' ‘(RSA) to the list of k//nown hosts.
oracle@'s password:
oracle.tar                                                                                                                            100% 3268MB  26.4MB/s   02:04

To copy whole directory, use –r option. In the following example, I will copy wole directory /u01/backup from to the current directory (/u01) on current host to specify current directory on current server, use “.”.
[salman@MYDBSERVER u01]$  scp -r oracle@  .

No comments:

Post a Comment

Popular Posts - All Times