Sunday, 29 January 2012


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  and the remote hostname is
Test-serv and IP is .The local user is kumar and remote user is  warren  in all of the examples.

Example 1)
To send a file  from a  local host to remote host.

/home/kumar$ rcp   Audit_document.txt    warren@

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.

Example 2)
To receive   a file from remote host to local  host.
/home/kumar$ rcp    warren@   .
This  copies the file  Meal_pass2.prt  in /home/warren/global  directory of
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

Example 3)
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   warren@
This copies  the entire directory localdir(its sub directories)  to  $HOME directory of  warren@

More examples:
  • To  copy  two files  booked_ticket1.txt  , booked_ticket2.txt   to /var/docs directory of
rcp    booked_ticket.txt   booked_ticket2.txt   warren@ /var/docs
rcp  booked_ticket?.txt    warren@ /var/docs

  • To  copy  the file  ‘pattern-styles.tar.gz’    to    /home/warren/images  directory of  as  style1.tar.gz with same  time stamp.
rcp    -p    pattern-styles.tar.gz    warren@ images/style1.tar.gz

No comments:

Post a Comment