ACGC - Winnipeg

Transferring files across the network



This tutorial will illustrate how to transfer individual files or complete directory trees for one Unix system to another. Login to your ACN Unix account using either vncviewer or Putty.

1. Create a gzipped tar archive of one of your directories


For this example, we'll create a tar archive of your tutorials directory. Make sure you are in your $HOME directory, and then type

tar cvfp tutorials.tar tutorials

The tar command recursively copies a directory and all its subdirectories and files into a single file. The command line options used here are:

c - create an archive
v - verbose progress report
f - the next argument is the name of the file to hold the archive (always should have a .tar extension)
p - preserve all file attributes (eg. permissions, times, dates). Always use this with tar unless you have a good reason not to.

You should now have a file called tutorials.tar. Verify this using 'ls -l'. Next, compress the file for to a smaller size, for faster transfer across the network:

gzip tutorials.tar

The tar file should now be replaced with a file called tutorials.tar.gz.

2. Upload the file to your account on coe01

sftp is a secore file transfer protocol that encrypts your files during transfer between Unix hosts. Connect to your coe01 account at the University of Calgary using 'sftp userid@hostname' eg.
 
{pinawa:/home/plants/frist}sftp frist@coe01.ucalgary.ca
Connecting to coe01.ucalgary.ca...
The authenticity of host 'coe01.ucalgary.ca (136.159.169.6)' can't be established.
RSA key fingerprint is 51:b9:90:67:c0:1b:49:23:6c:8f:ec:cd:35:3e:db:76.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'coe01.ucalgary.ca,136.159.169.6' (RSA) to the list of known hosts.
frist@coe01.ucalgary.ca's password:
sftp>

You now have the sftp prompt. You can upload the file to coe01

sftp> put tutorials.tar.gz
Uploading tutorials.tar.gz to /export/home/frist/tutorials.tar.gz
sftp>
You can verify the success of the transfer by typing 'ls -l' at the sftp> prompt. If successful, you disconnect from coe01 by typing 'quit'.

3. Login to coe01 at the command line

ssh is a secure protocol that lets you run a remote command line session in which traffic between the two hosts is encrypted. Start a session with 'ssh -l userid   hostname' eg.
{pinawa:/home/plants/frist}ssh -l frist coe01.ucalgary.ca
frist@coe01.ucalgary.ca's password:
Last login: Mon Sep 11 16:53:55 2006 from mcclab54.cc.uma
Sun Microsystems Inc. SunOS 5.9 Generic May 2002
coe01:/export/home/frist 33 %

4. Recreate the directory structure from the .tar.gz file

No that you are logged into coe01, you can uncompress your .tar.gz file by typing

gunzip tutorials.tar.gz

which recreates the .tar file. Finally, recreate the directory tree by typing

tar xvfp tutorials.tar

Note that we are now using the 'x' option, which tells tar to extract files from the archive.
Make sure to verify that you tutorials directory has been recreated by typing 'ls -l'. When finished, delete your tar file by typing 'rm tutorials.tar'.