Solaris Advanced User's Guide

Copying Files Remotely (rcp)

The rcp command enables you to copy files from one machine to another. This command 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 the command syntax for cp.


Note –

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


Copying Files From a Remote Machine

To copy from a remote machine to your machine, use the rcp command with the following syntax.


$ rcp machinename:source destination

In the previous example, 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 /etc/hosts from the remote machine starbug to the /tmp directory on the local machine venus.


venus$ rcp starbug:/etc/hosts /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 venus, type the following command.


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

Copying Files From Your Machine to Another

To copy files from your local machine to a remote machine, use the following command syntax.


$ rcp source machinename:destination

In the previous example, 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 to copy the file newhosts from your /tmp directory to the /tmp directory on the remote machine starbug.


venus$ cd /tmp
venus$ rcp newhosts starbug:/tmp
venus$

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