This article talks about how to use RCP to transfer files in Ubuntu Linux.
For related subjects, please refer to the SOC Table of Contents.
Using the RCP command is usually the simplest way to copy files from one computer system to another, and does not require starting an FTP session or the need to log in to the remote system.
The RCP command has the following syntax and formatting:
rcp [option] [file directory] [target directory]
Where the main options are:
-p Preserves file modification and access times.
-r Recursively copies the entire directory.
Note that the file directory and target directory need to have “[user]@[host]:” prefixed before it if that specific directory is not on your local system. Where user is the user of the host system, and host is the host’s IP address.
For example, if we wish to copy the file test.txt from the directory home/ubuntu/test_folder1 on the computer we are currently on and paste it to the home folder of the root account on a computer with the IP address 192.168.0.88, both computers need to have a .rhosts file in the user’s home directory with authorized users in the file. The command would look something like this:
rcp /home/ubuntu/test_folder1/test root@192.168.0.88:/home
If we were to reverse the process and copy the file from the host to the computer you are currently on, you would use the following. You can opt to not specify the target directory, which defaults for the file to be copied to your home folder. Note that there is a “.” before specifying the target directory, which you must have even if you don’t specify.
rcp root@192.168.0.88:/home/test ./test_folder2