Linux rcp Command
The Linux rcp command is used to copy remote files or directories.
The rcp command is used for remote file or directory copying. If more than two files or directories are specified, and the final destination is an existing directory, it will copy all the specified files or directories into that directory.
Syntax
rcp [-pr][source file or directory][destination file or directory]
or
rcp [-pr][source file or directory...][destination file]
Parameters:
-p Preserves the attributes of the source file or directory, including owner, group, permissions, and time.
-r Recursively processes the specified directory and its subdirectories.
Example
Use the rcp command to copy a remote file to the local machine for backup.
Assuming the local host's current account is rootlocal, and the remote host's account is root, to copy the file "testfile" from the remote host's (218.6.132.5) home directory to the local directory "test", enter the following command:
rcp [email protected]:./testfile testfile # Copy remote file to local
rcp [email protected]:home/rootlocal/testfile testfile
# Requires the current login account cmd to log into the remote host
rcp 218.6.132.5:./testfile testfile
Note: The "rcp" command does not return any messages after execution. Simply check if the file "testfile" exists in the "test" directory. If it exists, the remote copy operation was successful; otherwise, it failed.