FTP or File Transfer Protocol is a program that you can use to transfer files between two machines on a network. In order to use FTP to transfer a file, both machines involved in the transfer must be attached to the network.

To transfer a file you run the program ftp from one of the machines involved in the transfer and give it the name of the other machine. Depending on the location of the file you wish to transfer and the direction the file has to go (i.e. from the first machine to the second or vice versa) you would issue the appropriate commands and the transfer would be complete.

The following is the transfer of a file between two UNIX machines (one machine is called “home_unix” and the other is called “cunix”). We are going to send a file called “homework” from “home_unix” to “cunix” and we will initiate the transfer from “home_unix”

home_unix:$ ftp cunix
Connected to cunix.cc.wikiconsole.com.
cunix.cc.wikiconsole.com FTP server (Version wu-2.4.2-academ

[BETA-12](1) Sun Jan 19 23:05:28 CST 1997) ready.
Name (cunix:sauce): shender 
(I typed in shender)
331 Password required for shender.
230 User shender logged in.
Remote system type is UNIX.
Using binary mode to transfer files.


The two machines are now ready to transfer the file.

Before you go any further you should type help at the ftp prompt to see what commands are available to you.

! debug mdir sendport site $ dir mget put size account disconnect mkdir pwd status append exit mls quit struct ascii form mode quote system bell get modtime recv sunique binary glob mput reget tenex bye hash newer rstatus tick case help nmap rhelp trace cd idle nlist rename type cdup image ntrans reset user chmod lcd open restart umask close ls prompt rmdir verbose cr macdef passive runique ? delete mdelete proxy send


Typing help will give you more specific help on how to use each of these commands. Let’s say we want to put the file “homework” into a subdirectory on “cunix” called “test.” We first have to change to that directory by issuing the cd command at the “ftp>” prompt.

ftp> cd test


Now we will send the file from “home_unix” to “cunix” in the following way. 
ftp> put homework
local: homework remote: homework
200 PORT command successful.
150 Opening BINARY mode data connection for homework.
226 Transfer complete.

The file “homework” is now waiting for you in your directory on the machine “home_unix.” If you had wanted to transfer the file from “home_unix” to “cunix” you would have done the same thing except that you would have issued the following command to start the transfer:

ftp> get homework

If you read the messages when logging in it stated you were using binary mode. If you are transferring text files you should use ascii mode otherwise you should use binary mode. To switch between modes just type the mode you want at the command line:

ftp> ascii
200 Type set to A.
or use:

ftp> bin
200 Type set to I.