Example uses of the command "rcp"

A Brief Introduction

Man's hand holding computer mouse
Erik Kalibayev/Moment Open/Getty Images

The following examples illustrate typical uses of the command rcp for copying files between computers.

With the rcp (remote copy) command you can copy from and to a remote computer or between remote computers. The rcp command is similar to cp except that the remote computer and possibly the username on the remote computer needs to be prefixed to the file name.

To be able to use the rcp command, both computers need a ".rhosts" file in the user's home directory, which would contain the names of all the computers that are allowed to access this computer along with the user name.

Here is an example of an .rhosts file:


zeus.univ.edu jdoe
   athena.comp.com mjohnson

The ftp command or scp command can be used to copy files between computers if no .rhosts file is set up.

If you want to copy a file "customers.txt" in the directory "/usr/data/" from a computer "tomsnotebook" to the current directory, you would type the following at a command line:


rcp tomsnotebook:/usr/data/customers.txt .

The period "." at the end means "this" directory, that is, the directory from which the command was executed. You could specify any other directory instead.

You can copy a complete directory by adding a "-r" after the "rcp":


rcp -r tomsnotebook:/usr/data .

rcp document1 zeus.univ.edu:document1 

Copies "document1" from the local machine to the user's home directory on the computer with URL zeus.univ.edu, assuming that the user names are the same on both systems.


rcp document1 jdoe@:zeus.univ.edu:document1

Copies "document1" from the local machine to the home directory of user "jdoe" on the computer with URL zeus.univ.edu.


rcp zeus.univ.edu:document1 document1

Copies "document1" from the remote computer zeus.univ.edu to the local machine with the same name.


rcp -r documents zeus.univ.edu:backups 

Copies the directory "documents", including all subdirectories, from the local machine to the directory "backups" in the user's home directory on the computer with URL zeus.univ.edu, assuming that the user names are the same on both systems.


rcp -r zeus.univ.edu:backups/documents study

Copies the directory "documents", including all subdirectories, from the remote machine to the directory "study" on the local machine.

More From Us