NIU Department of Mathematical SciencesThe file transfer protocol, or FTP, is used to ship large files between hosts efficiently. As with all original Internet applications, its user inetrface is not up to today's standards, but it still has its place in the 'Net toolbox of every user.
Even if you are using a modern Web browser such as Netscape, some places you visit while surfing the network might in fact be FTP servers. This new interface greatly simplifies using FTP, but you still might want to know how this works behind the scenes.
Perhaps the most interesting feature of FTP is that the server can be programmed to provide access to some documents not only to people with accounts on the host computer, but to everyone. This method, anonymous FTP, is widely used to distribute software, documentation, papers, even books.
Thus there are two types of FTP connections. One requires that you have a valid account on the server. As an example, you may be visiting some other institution, and you may want to access your private files on our system over the network. The other type is anonymous FTP, in which a server is configured to let anyone in.
The standard FTP application, present on all Unix computers and rather
primitive, is called
ftp. There is also a more powerful and friendlier version,
ncftp. If you decide to switch to it permanently after
trying it out, just put the line
alias ftp ncftpin your .cshrc file.
Those who regularly use a Web browser will find it even easier to use it for file transfers, and forget the specialized FTP programs entirely.
If you are not familiar with Web browsers, you should first read about basics of Web surfing.
FTP mode is accessed by telling the browser to connect to a URL such as
ftp://ftp.math.niu.edu/pub/(click on this link to try it!) This will establish an anonymous FTP session with the server ftp.math.niu.edu. You can now go into subdirectories and download files simply by clicking on them.
To use regular FTP, change the syntax of the URL slightly - use
ftp://joeblow@host.math.niu.edu/instead. If the account joeblow requires a password, you will be prompted to type it in.
Note: Please use a suitable computer name, e.g. your own office workstation or a graduate lab machine.
If the currently active FTP connection allows you not only to download files but also to send files to the server (e.g. when you've accessed your own account on one of our computers), the browser should let you select `Upload file...' (or similar) from its `File' menu.
An `old fashioned' FTP
sessionftp hostname; after the
connection is establshed, the user has to log in using either a
username and password corresponding to a real account (in which case he
is placed in his home directory), or the username ftp and the
password being his e-mail address (then the starting point will be the
directory that was set up as the repository of public information).
Since ncftp is designed with anonymous ftp in mind, it performs
the anonymous login for you. If you want to be prompted for a real
username and password, you have to specify a -u flag, as in
ncftp -u ftp.math.niu.edu.
Anonymous FTP. In the example that follows, we connect to a computer in Finland and download a file from it; some messages from ftp have been deleted for brevity. The username `ftp' indicates an anonymous FTP connection; most servers will accept it as equivalent to the traditional (and easily misspelled!) `anonymous'.
behr.muir 6 % ftp nic.funet.fi Connected to nic.funet.fi. Name (nic.funet.fi:behr): ftp 331 Guest login ok, give your E-mail address for password. Password: behr@ 230-Guest `behr@muir.math.niu.edu' login ok. ftp> cd /pub/sci/math ftp> ls -l -rw-rw-r-- 1 rahola 1050 Aug 5 1994 00README drwxrwxr-x 2 jhaataja 8192 Jun 24 1993 c++ drwxrwxr-x 2 rahola 8192 Jun 24 1993 matlab ftp> cd matlab ftp> ls 00README testmats.m ftp> bin 200 Type set to I. ftp> get testmats.m 150 Opening BINARY mode data connection for /pub/sci/math/matlab/testmats.m (85029 bytes). 226 Transfer complete. ftp> quitA copy of the file
testmats.m is now in your local directory.
Be careful -- ftp will overwrite an existing file by that name.
Note that just before transfer we typed bin. This enables
binary transfer mode; if this isn't done, and if the file
in question contains anything other than plain text, the copy
you get at your end will be garbled. The newer ncftp which
was mentioned before has binary mode as its default, so you don't
have to worry about switching the transfer mode if you use it instead.
You can download several files at once using the mget
(`multiple get') command and wildcards; for example,
mget *.m would download all files whose names end
with .m.
Note that the downloaded files will end up in the directory
in which you were when the ftp command was issued. If
you want to `move' elsewhere during a session, you can do that
with the lcd (`local change directory') command; e.g.
ftp> lcd Misc will make subsequent downloads go to your
Misc subdirectory. If you get disoriented during an FTP
session, you can execute Unix commands using the so-called
shell escape: for instance, ftp> !ls will list
the files present in the current directory on your system,
rather than on the FTP server.
The put command lets you upload files from your computer
(the client) to the server, provided you have the necessary
permissions. Anonymous FTP servers sometimes have an area which
is writeable (usually a directory called incoming) where
everyone can leave things.
Regular FTP.
Normal (as opposed to anonymous) FTP connections are very similar,
except you must log in using a valid `real' username and password.
You will then gain access to the files in your home directory on
the server. Since you then have a read and write permission for
those files, you can download and upload files without a problem;
files can also be deleted using the dele command, e.g.
dele junk.
If you prefer ncftp, you must change its default behavior
so it will not try to log you in as an anonymous user: for
example, ncftp -u ftp.math.niu.edu will do the trick.
There are many other options and commands available in both
ftp and ncftp; see the on-line manual pages.