How to use UNIX File Transfer Protocol (FTP)

By Nicholas Seet

FTP enables files to be transferred from one machine on a network to another. FTP is useful as it allows you to store or retrieve files from any computer in the world. Many different FTP 'clients' or programs have been written, but the first and most commonly available is the text mode FTP which can always be found on Unix systems, or in 'DOS' under Windows'95 or NT.


Learn by Example

Learn by Syntax (advanced)


Learn by Example

Just say someone tells you to 'Go and get the file list.txt from ftp.cdrom.com/pub/games/' or you may have found a file in 'archie', the file searching program.



1. At your command prompt type:

          ftp ftp.cdrom.com

FTP starts the program, and connects to the site ftp.cdrom.com


2. You will see something similar to:

          >Connected to sunsite.cnlab-switch.ch.
          >220 wcarchive.cdrom.com FTP server (Version wu-2.4.2(18) Thu
	  >Dec119:28:12 MET 1997) ready.
          >Name (carchive.cdrom.com:user):
Type:
          ftp
You will then see:
          >331 Guest login ok, send your complete e-mail address as password.
          >Password:
Type in your email address. (You don't really have to type in the stuff after the @ symbol)


3. After the welcome message, you are now 'in' the site.
We must now change our directory to the directory '/pub/games'.

Type:

          cd pub

Type:

          dir
to see a list of all the files there. You should see the 'games' directory in the list:
          drwxr-xr-x   6 731       730 512 Nov  4 05:11 games


4. Use 'cd' to change into the remaining directories:

Type:

          cd games


5. Use 'dir' to find the file:

Type:

          dir l*
to get a listing of all files which start with 'l'. You should see:
          -rw-rw-r--  1 2066  ftp-game  234868 Jun 30  1997 list.txt


6. To download, type:

          bin

Type:

          get list.txt
and type 'y' when asked to confirm.


6b. To upload:


7. Logging off. Type:

          bye
to close the connection and quit FTP.



Learn by Syntax

Following are the basic commands that will allow you to successfully ftp.
Click on them or scroll down for notes on usage.

Advanced commands:

Where the contents of [square brackets] are customizable and
[filespec] means either a full file name (ie. 'list.txt') or a filename with wildcards
ie. 'l*' means all files beginning with 'l', and '*.txt' means all files ending with '.txt'


          ftp [sitename]

  • Connects to [sitename]
  • Login: ftp
  • Password: [emailaddress]


          cd [directory]

  • Changes to [directory]


          pwd

  • Print working directory (tells you which directory you are in)


          dir [filespec]

  • Lists details about the filespec
  • Alternate is 'ls -aFl'


          bin

  • Changes to binary mode
  • You must do this!


          prompt

  • Turns off confirming uploads/downloads


          hash

  • Turn on hash indicators for download/upload status


         get [filename]

  • Downloads [filename]


         mget [filespec]

  • Multiple download of [filespec] files


         put [filename]

  • Uploads [filename] from your current local directory


         mput [filenspec]

  • Uploads multiple files matching [filespec]


Advanced

         lcd

  • Changes your local directory (the directory from which you started 'ftp' from).


         !

  • Allows you to suspend ftp and use your command prompt, type 'exit' to return to 'ftp'.