Go to main content

手册页部分 1:用户命令

退出打印视图

更新时间: 2022年7月27日 星期三
 
 

rcp(1)

名称

rcp - 远程文件复制

用法概要

rcp [-p] filename1 filename2
rcp [-pr] filename... directory

描述


Caution

注意  -  All data exchanges over this protocol are performed without encryption, and have no protection against spoofing or snooping of traffic.The in.rshd server is disabled by default on Oracle Solaris and most other modern operating systems, and both the in.rshd server and the rcp command may be removed in future versions of Oracle Solaris.Use of the scp(1) or sftp(1) utilities is strongly recommended instead.


rcp 命令会在计算机之间复制文件。每个 filenamedirectory 参数可以是以下形式的远程文件名:

hostname:path

也可以是本地文件名(不含 :(冒号)字符,或任何 :(冒号)字符前不含 /(反斜杠))。

hostname 可以是一个 IPv4 或 IPv6 地址字符串。请参见 inet(4P)inet6(4P)。由于 IPv6 地址已经包含冒号,因此,使用 IPv6 地址时,hostname 应括在一对方括号中。否则,第一个冒号会解释为 hostnamepath 之间的分隔符。For example,

[1080::8:800:200C:417A]:tmp/file

如果 filename 不是全路径名,则会将其解释为相对于 hostname 上的起始目录的路径名。远程主机上的 path 可使用 \ " ' 引起,以便能够远程解释元字符。

rcp 不会提示用户输入口令。It uses your current local user name, which must be accepted on hostname to allow remote command execution by rsh(1).

rcp 可以处理源和目标文件均不在当前计算机上的第三方副本。主机名也可以采用以下形式

username@hostname:filename

to use username rather than your current local user name as the user name on the remote host.使用并非全路径名的文件名时,系统会将其解释为与远程主机上名为 username 的用户的起始目录相对的文件名。

选项

支持以下选项:

–p

尝试为每个副本提供与原始文件相同的修改时间、访问时间、模式以及 ACL(如适用)。

–r

复制根目录位于 filename 的每个子树;此时,目标必须是一个目录。

退出状态

将返回以下退出值:

0

所有文件都已成功复制。

>0

An error occurred.

请参见“附注”部分了解有关退出代码的警告。

属性

有关下列属性的说明,请参见 attributes(7)

属性类型
属性值
可用性
network/legacy-remote-utilities
CSI
Enabled
Interface Stability
Obsolete

另请参见

cpio(1), ftp(1), rlogin(1), rsh(1), rsync(1), scp(1), sftp(1), tar(1), inet(4P), inet6(4P), ip6(4P), hosts.equiv(5), attributes(7), in.rshd(8)

附注

rcp 用来在不同主机之间进行复制。按照以下方式使用 rcp 尝试将一个文件复制到其自身时:

example% rcp tmp/file myhost:/tmp/file

会导致文件严重损坏。

复制目标为文件而不是目录时,rcp 可能会出现异常故障。

rcp can become confused by output generated by commands in a $HOME/.profile or other shell startup file on the remote host.

处理第三方副本时,rcp 要求源主机具备在远程主机上执行命令的权限。

rcp 无法正确处理符号链接。Use rsync(1), or tar(1) or cpio(1) piped to ssh to obtain remote copies of directories containing symbolic links or named pipes.

如果忘记使用引号将用于远程主机的元字符引起,则会收到无法理解的错误消息。

将 ACL 复制到不支持 ACL 的文件系统时,rcp 会失败。

rcp 支持 CSI,但处理用户名、主机名和域时除外。

使用 rcp 处理第三方副本时,如果任一台远程计算机未运行 Solaris,则退出代码不可依赖。也就是说,退出代码表明操作成功执行时实际上可能发生了错误,或者虽然退出代码表明发生了错误,但复制可能已经彻底成功完成。

将来的 Oracle Solaris 发行版可能会删除此技术。

History

Support for Kerberos, including the options –a, –k, –K, –PN, –PO, and –x, was added in Solaris 10 3/05 and removed in Oracle Solaris 11.4.0.Prior to Solaris 10, a kerberized version was available in the Sun Enterprise Authentication Mechanism (SEAM) add-on package for Solaris.

Support for IPv6 was added in Solaris 8.

The rcp command, including support for the options –p and –r, has been present since the initial release of Solaris.