JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
System Administration Guide: Network Services     Oracle Solaris 10 8/11 Information Library
search filter icon
search icon

Document Information

Preface

Part I Network Services Topics

1.  Network Service (Overview)

2.  Managing Web Cache Servers

3.  Time-Related Services

Part II Accessing Network File Systems Topics

4.  Managing Network File Systems (Overview)

5.  Network File System Administration (Tasks)

6.  Accessing Network File Systems (Reference)

Part III SLP Topics

7.  SLP (Overview)

8.  Planning and Enabling SLP (Tasks)

9.  Administering SLP (Tasks)

10.  Incorporating Legacy Services

11.  SLP (Reference)

Part IV Mail Services Topics

12.  Mail Services (Overview)

13.  Mail Services (Tasks)

14.  Mail Services (Reference)

Part V Serial Networking Topics

15.  Solaris PPP 4.0 (Overview)

16.  Planning for the PPP Link (Tasks)

17.  Setting Up a Dial-up PPP Link (Tasks)

18.  Setting Up a Leased-Line PPP Link (Tasks)

19.  Setting Up PPP Authentication (Tasks)

20.  Setting Up a PPPoE Tunnel (Tasks)

21.  Fixing Common PPP Problems (Tasks)

22.  Solaris PPP 4.0 (Reference)

23.  Migrating From Asynchronous Solaris PPP to Solaris PPP 4.0 (Tasks)

24.  UUCP (Overview)

25.  Administering UUCP (Tasks)

26.  UUCP (Reference)

Part VI Working With Remote Systems Topics

27.  Working With Remote Systems (Overview)

28.  Administering the FTP Server (Tasks)

29.  Accessing Remote Systems (Tasks)

Accessing Remote Systems (Task Map)

Logging In to a Remote System (rlogin)

Authentication for Remote Logins (rlogin)

/etc/hosts.equiv File

.rhosts File

Linking Remote Logins

Direct or Indirect Remote Logins

What Happens After You Log In Remotely

How to Search for and Remove .rhosts Files

How to Find Out If a Remote System Is Operating

How to Find Who Is Logged In to a Remote System

How to Log In to a Remote System (rlogin)

How to Log Out From a Remote System (exit)

Logging In to a Remote System (ftp)

Authentication for Remote Logins (ftp)

Essential ftp Commands

How to Open an ftp Connection to a Remote System

How to Close an ftp Connection to a Remote System

How to Copy Files From a Remote System (ftp)

How to Copy Files to a Remote System (ftp)

Remote Copying With rcp

Security Considerations for Copy Operations

Specifying Source and Target

How to Copy Files Between a Local and a Remote System (rcp)

Part VII Monitoring Network Services Topics

30.  Monitoring Network Performance (Tasks)

Glossary

Index

Remote Copying With rcp

The rcp command copies files or directories between a local and a remote system or between two remote systems. You can use this command from a remote system (after logging in with the rlogin command) or from the local system (without logging in to a remote system).

With rcp, you can perform the following remote copy operations:

If you have the automounter running, you can perform these remote operations with the cp command. However, the range of cp is constrained to the virtual file system that is created by the automounter and to operations relative to a user's home directory. Because rcp performs the same operations without these constraints, this section describes only the rcp versions of these tasks.

Security Considerations for Copy Operations

To copy files or directories between systems, you must have permission to log in and copy files.


Caution

Caution - Both the cp and rcp commands can overwrite files without warning. Ensure that file names are correct before executing the command.


Specifying Source and Target

With the rcp command in the C shell, you can specify source (the file or directory you want to copy) and target (the location into which you will copy the file or directory) with either absolute or abbreviated path names.

Absolute Path Names
Abbreviated Path Names
From Local System
mars:/home/jones/myfile.txt
~jones/myfile.txt
After Remote Login
/home/jones/myfile.txt
~jones/myfile.txt

Absolute path names identify files or directories that are mounted on a particular system. In the previous example, the first absolute path name identifies a file (myfile.txt) on the mars system. Abbreviated path names identify files or directories relative to a user's home directory, wherever it might reside. In the previous first example, the abbreviated path name identifies the same file, myfile.txt, but uses “~” symbol to indicate the jones home directory:

~ = mars:/home/jones

The examples on the second line demonstrate the user of absolute and abbreviated path names after a remote login. No difference is evident for the abbreviated path name. However, because the remote login operation mounted the jones home directory onto the local system (parallel to the local user's home directory), the absolute path name no longer requires the system name mars. For more information about how a remote login operation mounts another user's home directory, see What Happens After You Log In Remotely.

The following table provides a sample of absolute and abbreviated path names that are recognized by the C shell. The sample uses the following terminology:

Table 29-4 Allowed Syntaxes for Directory and File Names

Logged in to
Syntax
Description
Local system
.
The local working directory
path/filename
The path and filename in the local working directory
~
The current user's home directory
~/path/filename
The path and filename beneath the current user's home directory
~user
The home directory of user
~user/path/filename
The path and filename beneath the home directory of user
remote-system:path/filename
The path and filename in the remote working directory
Remote system
.
The remote working directory
filename
The filename in the remote working directory
path/filename
The path and filename in the remote working directory
~
The current user's home directory
~/path/filename
The path and filename in the current user's home directory
~user
The home directory of user
~/user/path/filename
The path and filename beneath the home directory of user
local-system:path/filename
The path and filename in the local working directory

How to Copy Files Between a Local and a Remote System (rcp)

  1. Ensure that you have permission to copy.

    You should at least have read permission on the source system and write permission on the target system.

  2. Determine the location of the source and target.

    If you don't know the path of the source or target, you can first log in to the remote system with the rlogin command, as described in How to Log In to a Remote System (rlogin). Then, navigate through the remote system until you find the location. You can then perform the next step without logging out.

  3. Copy the file or directory.
    $ rcp [-r] source-file|directory target-file|directory
    rcp

    (No options) Copies a single file from the source to the target.

    -r

    Copies a directory from the source to the target.

    This syntax applies whether you are logged in to the remote system or in to the local system. Only the path name of the file or directory changes, as described in Table 29-4 and as illustrated in the following examples.

    You can use the “~” and “.” characters to specify the path portions of the local file or directory names. Note, however, that “~” applies to the current user, not the remote system, and that “.” applies to system you are logged in to. For explanations of these symbols, see Table 29-4.

Example 29-8 Using rcp to Copy a Remote File to a Local System

In this example, rcp is used to copy the file letter.doc from the /home/jones directory of the remote system pluto to the working directory (/home/smith) on the local system, earth:

earth(/home/smith): rcp pluto:/home/jones/letter.doc .

In this instance, the rcp operation is performed without a remote login. Here, the “.” symbol at the end of the command line refers to the local system, not the remote system.

The target directory is the also local user's home directory, so it can also be specified with the “~” symbol.

Example 29-9 Using rlogin and rcp to Copy a Remote File to a Local System

In this example, the rcp operation is run after the rlogin command is executed to copy a file from a remote to a local system. Although the flow of the operation is the same as that of the previous example, the paths change to allow for the remote login:

earth(/home/smith): rlogin pluto
.
.
.
pluto(/home/jones): rcp letter.doc ~

Using the “.” symbol at the end of the command line would be inappropriate in this instance. Because of the remote login, the symbol would simply refer to the remote system; essentially directing rcp to create a duplicate file. The “~” symbol, however, refers to the current user's home directory, even when the login is to a remote system.

Example 29-10 Using rcp to Copy a Local File to a Remote System

In this example, rcp is used to copy the file notice.doc from the home directory (/home/smith) of the local system earth to the /home/jones directory of the remote system, pluto:

earth(/home/smith): rcp notice.doc pluto:/home/jones

Because no remote file name is provided, the file notice.doc is copied into the /home/jones directory with the same name.

In this instance, the rcp operation from the previous example is repeated, but rcp is entered from a different working directory on the local system (/tmp). Note the use of the “~” symbol to refer to the current user's home directory:

earth(/tmp): rcp ~/notice.doc pluto:/home/jones

Example 29-11 Using rlogin and rcp to Copy a Local File to a Remote System

In this example, the rcp operation is run after the rlogin command is executed to copy a local file to a remote directory. Although the flow of the operation is the same as that of the previous example, the paths change to allow for the remote login.

earth(/home/smith): rlogin pluto
.
.
.
pluto(/home/jones): rcp ~/notice.doc .

In this instance, the “~” symbol can be used to denote the current user's home directory, even though it is on the local system. The “.” symbol refers to the working directory on the remote system because the user is logged in to the remote system. Here is an alternative syntax that performs the same operation:

pluto(/home/jones): rcp earth:/home/smith/notice.doc /home/jones