rcp Command in Linux with examples

There comes a time while using LINUX when there is a need to copy some information stored in a file to another computer. This can be done simply using rcp command line utility . Obviously there exists some other methods to complete the above mentioned task which are more secure (like scp or rsync) but this command lets you do this in the simple way and a LINUX beginner can use this command to copy files from one computer to another computer.

Here’s the syntax of rcp command:

// syntax of rcp command

rcp [-p] [-r] file name ... directory

Using rcp command

To simply use the rcp command, just provide the source and destination to rcp command with a colon used to separate the host and the data.

/* using rcp command
to send a file from local
host to remote host */

rcp /mydirectory/kt.txt kartik:one/kt.txt

/* the example
above is to send a file
not to receive a file
from remote host */

What actually happening in the above example is the file named kt.txt whose path is given as /mydirectory/kt.txt is getting transferred from this local path (/mydirectory) that is you can say from a local host to the remote system named kartik and the file on that system will be placed in the directory one(as path one/kt.txt is given).



Options for rcp command

  • -r : This option is used when there is a need to cpy an entire directory.
  • -p : This option allows the copy to have the modification times, access times, modes and ACLs if applicable as the original file.
  • file name : refers to the name of the file.
  • directory : refers to the name of directory

Examples of using rcp command