Thursday, June 17, 2010

SCP Command in Linux

scp stands for secure copy, which is a remote file copy program

The scp command allows you to copy files over ssh connections. This is pretty useful if you want to transport files between computers, for example to backup something.

The scp command can be used in three ways:

1.To copy from a (remote) server to your computer

scp -r [login name@ip address] : [/path/filename] .

Ex: scp -r sravan@10.1.14.36:/home/sravan/Desktop/test /home/subin/Desktop

Ex: scp -r sravan@10.1.14.36:/home/sravan/Desktop/test .


Here are the meaning of scp command options:

* -r = recursively copy entire directory
* . = current directory

'/path/filename' is the complete directory path and name where the file resides.

'login name@ip address ' is the target/destination computer. You have to provide your login name and ip address and will be asked for user password.

Dot (.) at the end of the command means the files will be copied to the current directory. Of course you can change the destination to any directory you wish, just type the full path and directory name to replace the dot(.).

2.To copy from your computer to a (remote) server

scp -r [/path/filename] [login name@ip address] : .

Ex : scp -r /home/subin/Desktop/abc sravan@10.1.14.36:.

Ex : scp -r /home/subin/Desktop/abc sravan@10.1.14.36:/home/sravan/Desktop

3.To copy from a (remote) server to another (remote) server.

In the third case, the data is transferred directly between the servers; your own computer will only tell the servers what to do.

scp yourusername@yourserver:/home/yourusername/examplefile yourusername2@yourserver2:/home/yourusername2/

Ex : scp sravan@10.1.14.108:/home/sravan/xyz subin@10.1.14.109:/home/subin

No comments:

Post a Comment