Transferring Files

Files can be transferred between various accounts on either the same or different host.

File Transfer Within the Same UNIX Host

For simple file transfers within the same UNIX host, you can use the cp command.

For info on using cp for copying files within the same account, see the ITS documentation
at Directory Commands.

To copy files between two user’s accounts, type:

    cp ~<username>/<path>/<filename>

The following example will take a copy of the file assign1 from the account
comp101 and will put a copy of the file in the account ttrojan in the directory
classes called hwassign.

    Example: cp ~comp101/assign1 ~ttrojan/classes/hwassign<

NOTE: This will work only if you have write permissions to the other user’s specified directory.

Between two UNIX Hosts at USC

For file transfers between two different hosts at USC, you can use the rcp command.
However, you need to be able to login to both hosts without a password. You can do this by setting up a
.rhosts file in both accounts. The syntax for the rcp command is:

    rcp <host>:~<username>/<filename>
    Example: rcp aludra:~ee101/hw1sol mizar:~htroy/classes/sol1

The above example will take a copy of the file hw1sol from the account ee101 on the host
aludra and put a copy of the file in the account htroy on the host mizar in the directory classes called sol1.

File Transfer Between Machines

For file transfer between machines, you can use the ftp command.

To use ftp between two UNIX hosts, you must have an account on both hosts.

You can also transfer files via email. Most e-mail applications allow you to insert a file into your
message. Some applications also allow you to send a file as a separate attachment. See ITS documentation on the supported email applications at our Email Documentation for more information.

If you are including a binary (executable) file into an email message, you will need to encode the file.
You do not need to encode a binary file if you are sending it as an attachment. To encode a file, type:

    uuencode <binary_filename> <label_name> >

Where <binary_filename> is the name of the binary file you wish to encode, <label_name> is the name of the file that will be created when the person receiving the encoded file decodes it (you can use the same name as the <binary_filename>), and <encoded_filename> is the name of the encoded file you are creating.

    Example: uuencode myprog yourprog > encodedprog

The above example will take the binary file myprog, encode it and createa new file called encodedprog. When the receiver decodes encodedprog, a file called yourprog will be created in their account.

To decode an encoded file, type:

    uudecode <filename>
    Example: uudecode encodedprog