OpenWindows Advanced User's Guide

9.3 Copying Files Remotely (rcp)

The rcp command allows you to copy files from one machine to another. It uses the remote machine's /etc/hosts.equiv and /etc/passwd files to determine whether you have unchallenged access privileges. The syntax for rcp is similar to that used for cp.


Note -

To copy subdirectories and their contents from one machine to another, use rcp -r.


9.3.1 Copying from Another Machine to Yours

To copy from a remote machine to your machine, the syntax is:

rcp machinename:source destination

where machinename is the name of the remote machine, source is the name of the file(s) you want to copy, and destination is the path name on your machine where you want the copied file(s) to reside.

The following example illustrates how to copy the file /home/dakota/doc/letter from the remote machine dakota to the /tmp directory on local machine blue:

$ rcp dakota:/home/dakota/doc/letter /tmp
$

You can also combine various abbreviations and syntaxes when using rcp. For example, to copy all of the files ending in .doc from user hank's home directory on remote machine fretful to the current directory on local machine blue, you would type the following:

$ rcp fretful:~hank/*.doc .
$

9.3.2 Copying from Your Machine to Another

To copy from your local machine to a remote machine, the syntax is reversed as follows:

rcp source machinename:destination

where source is the file(s) you want to copy, machinename is the name of the remote machine, and destination is the path name on the remote machine where you want the copied file(s) to reside.

The following example illustrates how you would copy the file austin from your directory ~/usa/texas to the directory ~hank/cities on the remote machine fretful (remember that ~ is your home directory and ~hank is user hank's home directory):

$ rcp ~/usa/texas/austin fretful:~hank/cities
$

For more information on the rcp(1) command and its options, refer to the man Pages(1): User Commands.