rcp is used to copy or send files or directories between two hosts. It can be used an alternative to ftp and related protocols like sftp, but no password is required to send files unlike ftp.
For rcp to work, various prerequisites are required ,which are same for the rsh command.(refer rsh)
Assume your hostname is Prod-serv and IP is 22.214.171.124 and the remote hostname is
Test-serv and IP is 126.96.36.199 .The local user is kumar and remote user is warren in all of the examples.
To send a file from a local host to remote host.
/home/kumar$ rcp Audit_document.txt email@example.com:
This sends the local file Audit_document.txt to the host Test-serv (you can use Test-serv in place of the IP address) and places it in the $HOME directory of warren.
With the name Audit_document.txt and owner of the file as warren.
To receive a file from remote host to local host.
/home/kumar$ rcp firstname.lastname@example.org:global/Meal_pass2.prt .
This copies the file Meal_pass2.prt in /home/warren/global directory of 188.8.131.52
to the current directory (/home/kumar denoted here by ‘.’ or dot).
rcp just like cp changes the modification time(time stamp) of the destination file to the latest time. To retain the same time stamp use rcp –p . The above example can be written as
To copy directories between hosts use rcp with –r option.
/home/kumar$ ls -ld localdir
drwxr-xr-x 2 kumar tools 256 Jul 14 2009 localdir
/home/kumar$rcp -r localdir email@example.com:
This copies the entire directory localdir(its sub directories) to $HOME directory of firstname.lastname@example.org.
- To copy two files booked_ticket1.txt , booked_ticket2.txt to /var/docs directory of 184.108.40.206
rcp booked_ticket.txt booked_ticket2.txt email@example.com: /var/docs
rcp booked_ticket?.txt firstname.lastname@example.org: /var/docs
- To copy the file ‘pattern-styles.tar.gz’ to /home/warren/images directory of 220.127.116.11 as style1.tar.gz with same time stamp.
rcp -p pattern-styles.tar.gz email@example.com: images/style1.tar.gz