You are on page 1of 6

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
cd stands for Change Directory. Now we are in the 'pub' directory.
Generally, you will find downloadable material in the 'pub' directory of most sites.
You must also make sure that you only use capitals when the directory has capitals in it,
otherwise it won't work!
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
You can tell that it is a directory because there is a 'd' at the far left.
If 'dir' does not work, then you must type 'ls -aFl'.

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
Because there is no 'd' at the far left, you know that it is a file, not a directory.
The 234868 is the file size, it is 234,868 bytes big (approx. 234Kb). It was last modified on the
30th June 1997.

6. To download, type:
bin
This will make your download in 'binary' form.
This mode will always work for all files, whereas the default mode 'ascii' will only work for text
files.
So always make sure you type 'bin' before you download or you will get garbage!
Type:
get list.txt
and type 'y' when asked to confirm.
'list.txt' will now download, and will soon be on the computer you ran 'ftp' from.
Alternately, if you want to download multiple files, you could type: 'mget *', this would download
*all* files in the directory; 'mget l*' would download all files beginning with 'l'.
If you do not wish to confirm each download one by one, type 'prompt' to turn that off. If you wish
to have a download indicator, type 'hash'.

6b. To upload:
To upload a file you must be in a directory you are allowed to upload into.
You would type 'put list.txt' if you wished to upload 'list.txt' or 'mput l*' to upload all files beginning
with 'l' for example.
Make sure that you type 'bin' again before you upload anything.

7. Logging off. Type:
bye
to close the connection and quit FTP.
If you have any questions type either 'man ftp' (for unix) or 'help ftp' (for windows) at your
command prompt;
...or email nik@ying.com



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.
ftp [sitename]
cd [directory]
pwd
dir [filespec]
bin
prompt
hash
get [filename]
mget [filespec]
put [filename]
mput [filespec]
Advanced commands:
lcd
!
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'.

You might also like