\chapter{FTP Tutorial and Site List}\label{app-ftplist-num}
\label{app-ftp}

\index{FTP!using|(}

FTP (``File Transfer Protocol'') is the set of programs that are used for
transferring files between systems on the Internet. Most UNIX,
VMS, and MS-DOS systems on the Internet have a program called {\tt ftp}
which you use to transfer these files, and if you have Internet access, the
best way to download the Linux software is by using {\tt ftp}. This appendix
covers basic {\tt ftp} usage---of course, there are many more functions and
uses of {\tt ftp} than are given here. 

At the end of this appendix there is a listing of FTP sites where 
Linux software can be found. Also, if you don't have direct Internet
access but are able to exchange electronic mail with the Internet,
information on using the {\tt ftpmail} service is included below.

If you're using an MS-DOS, UNIX, or VMS system to download files from the
Internet, then {\tt ftp} is a command-driven program. However, there are 
other implementations of {\tt ftp} out there, such as the Macintosh version
(called {\tt Fetch}) with a nice menu-driven interface, which is quite
self-explanatory. Even if you're not using the command-driven version of 
{\tt ftp}, the information given here should help.

\bigskip
{\tt ftp} can be used to both upload (send) or download (receive) files
from other Internet sites. In most situations, you're going to be downloading
software. On the Internet there are a large number of publicly-available
{\bf FTP archive sites}, machines which allow anyone to {\tt ftp} to them and
download free software. One such archive site is {\tt sunsite.unc.edu}, which
has a lot of Sun Microsystems software, and acts as one of the main Linux
sites. In addition, FTP archive sites {\bf mirror} software to each 
other---that is, software uploaded to one site will be automatically copied 
over to a number of other sites. So don't be surprised if you see the exact
same files on many different archive sites. 

\section{Starting {\tt ftp}}
Note that in the example ``screens'' printed
below I'm only showing the most important information, and what you see may
differ. Also, commands in {\em italics\/} represent commands that you type;
everything else is screen output.

To start {\tt ftp} and connect to a site, simply use the command
\begin{tscreen}
ftp \cparam{hostname}
\end{tscreen}
where \cparam{hostname} is the name of the
site you are connecting to.
For example, to connect to the mythical site
{\tt shoop.vpizza.com} we can use the command
\begin{tscreen}
ftp shoop.vpizza.com
\end{tscreen}

\section{Logging In}
When {\tt ftp} starts up we should see something like
\begin{tscreen}
Connected to shoop.vpizza.com. \\
220 Shoop.vpizza.com FTPD ready at 15 Dec 1992 08:20:42 EDT \\
Name (shoop.vpizza.com:mdw): 
\end{tscreen}
Here, {\tt ftp} is asking us to give the username that we want to login as
on {\tt shoop.vpizza.com}. The default here is {\tt mdw}, which is my username
on the system I'm using FTP from. Since I don't have an account on 
{\tt shoop.vpizza.com} I can't login as myself. Instead, to access 
publicly-available software on an FTP site you login as {\tt anonymous}, and
give your Internet e-mail address (if you have one) as the password.
So, we would type
\begin{tscreen}
Name (shoop.vpizza.com:mdw): {\em anonymous} \\
331-Guest login ok, send e-mail address as password. \\
Password: {\em mdw@sunsite.unc.edu} \\
230- Welcome to shoop.vpizza.com. \\
230- Virtual Pizza Delivery[tm]: Download pizza in 30 cycles or less \\
230- or you get it FREE! \\
ftp> 
\end{tscreen}
Of course, you should give your e-mail address, instead of mine, and it
won't echo to the screen as you're typing it (since it's technically a
``password''). {\tt ftp} should allow us to login and we'll be ready to
download software. 

\section{Poking Around}
Okay, we're in. {\tt ftp>} is our prompt, and the {\tt ftp} program is
waiting for commands. There are a few basic commands you need to know about. 
First, the commands
\begin{tscreen}
ls \cparam{file}
\end{tscreen}
and
\begin{tscreen}
dir \cparam{file}
\end{tscreen}
both give file listings (where \cparam{file} 
is an optional argument
specifying a particular filename to list). The difference is that {\tt ls}
usually gives a short listing and {\tt dir} gives a longer listing (that
is, with more information on the sizes of the files, dates of modification,
and so on).

The command
\begin{tscreen}
cd \cparam{directory}
\end{tscreen}
will move to the given directory (just like the {\tt cd} command on UNIX or
MS-DOS systems). You can use the command
\begin{tscreen}
cdup
\end{tscreen}
to change to the parent directory\footnote{The directory above the current 
one.}. 

The command 
\begin{tscreen}
help \cparam{command}
\end{tscreen}
will give help on the given {\tt ftp} \cparam{command} 
(such as {\tt ls} or
{\tt cd}). If no command is specified, {\tt ftp} will list all of the 
available commands.

If we type {\tt dir} at this point we'll see an initial directory
listing of where we are. 
\begin{tscreen}
ftp> {\em dir} \\
200 PORT command successful. \\
150 Opening ASCII mode data connection for /bin/ls. \\
total 1337 \\
\begin{verbatim}
dr-xr-xr-x  2 root     wheel         512 Aug 13 13:55 bin 
drwxr-xr-x  2 root     wheel         512 Aug 13 13:58 dev 
drwxr-xr-x  2 root     wheel         512 Jan 25 17:35 etc 
drwxr-xr-x 19 root     wheel        1024 Jan 27 21:39 pub 
drwxrwx-wx  4 root     ftp-admi     1024 Feb  6 22:10 uploads 
drwxr-xr-x  3 root     wheel         512 Mar 11  1992 usr 
\end{verbatim}
226 Transfer complete. \\
921 bytes received in 0.24 seconds (3.7 Kbytes/s) \\
ftp>
\end{tscreen}

Each of these entries is a directory, not an individual file which we can 
download (specified by the {\tt d} in the first column of the listing).
On most FTP archive sites, the publicly available software is under the
directory {\tt /pub}, so let's go there.

\begin{tscreen}
ftp> {\em cd pub} \\
ftp> {\em dir} \\
200 PORT command successful. \\
150 ASCII data connection for /bin/ls (128.84.181.1,4525) (0 bytes). \\
total 846 \\
\begin{verbatim}
-rw-r--r--   1 root     staff        1433 Jul 12  1988 README 
-r--r--r--   1 3807     staff       15586 May 13  1991 US-DOMAIN.TXT.2 
-rw-r--r--   1 539      staff       52664 Feb 20  1991 altenergy.avail 
-r--r--r--   1 65534    65534       56456 Dec 17  1990 ataxx.tar.Z 
-rw-r--r--   1 root     other     2013041 Jul  3  1991 gesyps.tar.Z 
-rw-r--r--   1 432      staff       41831 Jan 30  1989 gnexe.arc 
-rw-rw-rw-   1 615      staff       50315 Apr 16  1992 linpack.tar.Z 
-r--r--r--   1 root     wheel       12168 Dec 25  1990 localtime.o 
-rw-r--r--   1 root     staff        7035 Aug 27  1986 manualslist.tblms 
drwxr-xr-x   2 2195     staff         512 Mar 10 00:48 mdw 
-rw-r--r--   1 root     staff        5593 Jul 19  1988 t.out.h 
\end{verbatim}
226 ASCII Transfer complete. \\
2443 bytes received in 0.35 seconds (6.8 Kbytes/s) \\
ftp> 
\end{tscreen}

Here we can see a number of (interesting?) files, one of which is called
{\tt README}, which we should download (most FTP sites have a {\tt README}
file in the {\tt /pub} directory). 

\section{Downloading files}
Before downloading files, there are a few things that you need to take care
of. 
\begin{itemize}
\item {\bf Turn on hash mark printing.} {\em Hash marks} are printed to the
screen as files are being transferred; they let you know how far along the
transfer is, and that your connection hasn't hung up (so you don't sit
for 20 minutes, thinking that you're still downloading a file). In general,
a hash mark appears as a pound sign ({\tt \#}), and one is printed for every 
1024 or 8192 bytes transferred, depending on your system.

To turn on hash mark printing, give the command {\tt hash}.
\begin{tscreen}
ftp> {\em hash} \\
Hash mark printing on (8192 bytes/hash mark). \\
ftp>
\end{tscreen}

\item {\bf Determine the type of file which you are downloading.}
As far as FTP is concerned, files come in two flavors: {\em binary} and
{\em text}. Most of the files which you'll be downloading are binary files:
that is, programs, compressed files, archive files, and so on. However,
many files (such as {\tt README}s and so on) are text files. 

Why does the file type matter? Only because on some systems (such as MS-DOS
systems), certain characters in a text file, such as carriage returns, need to
be converted so that the file will be readable. While transferring in
binary mode, no conversion is done---the file is simply transferred 
byte after byte.

The commands {\tt bin} and {\tt ascii} set the transfer mode to binary and
text, respectively. {\em When in doubt, always use binary mode to transfer 
files}.
If you try to transfer a binary file in text mode, you'll corrupt the file
and it will be unusable. (This is one of the most common mistakes made
when using FTP.) However, you can use text mode for plain text files (whose
filenames often end in {\tt .txt}).

For our example, we're downloading the file {\tt README}, which is
most likely a text file, so we use the command
\begin{tscreen}
ftp> {\em ascii} \\
200 Type set to A. \\
ftp> 
\end{tscreen}

\item {\bf Set your local directory.} Your {\em local directory} is the
directory on your system where you want the downloaded files to end up. 
Whereas the {\tt cd} command changes the remote directory (on the remote
machine which you're FTPing to), the {\tt lcd} command changes the local
directory. 

For example, to set the local directory to {\tt /home/db/mdw/tmp}, use
the command
\begin{tscreen}
ftp> {\em lcd /home/db/mdw/tmp} \\
Local directory now /home/db/mdw/tmp \\
ftp>
\end{tscreen}
\end{itemize}

Now you're ready to actually download the file. The command
\begin{tscreen}
get \cparam{remote-name} \cparam{local-name}
\end{tscreen}
is used for this, where \cparam{remote-name} 
is the name of the
file on the remote machine, and \cparam{local-name} 
is the name
that you wish to give the file on your local machine. The 
\cparam{local-name} argument is optional; by default, 
the local filename is
the same as the remote one. However, if for example you're downloading
the file {\tt README}, and you already have a {\tt README} in your local
directory, you'll want to give a different 
\cparam{local-filename} 
so that
the first one isn't overwritten.

For our example, to download the file {\tt README}, we simply use
\begin{tscreen}
ftp> {\em get README} \\
200 PORT command successful. \\
150 ASCII data connection for README (128.84.181.1,4527) (1433 bytes). \\
\# \\
226 ASCII Transfer complete. \\
local: README remote: README \\
1493 bytes received in 0.03 seconds (49 Kbytes/s) \\
ftp>
\end{tscreen}

\section{Quitting FTP}
To end your FTP session, simply use the command
\begin{tscreen}
quit
\end{tscreen}
The command
\begin{tscreen}
close
\end{tscreen}
can be used to close the connection with the current remote FTP site;
the {\tt open} command can then be used to start a session with another
site (without quitting the FTP program altogether).

\begin{tscreen}
ftp> {\em close} \\
221 Goodbye. \\
ftp> {\em quit} 
\end{tscreen}

\section{Using {\tt ftpmail}}
\index{ftpmail@{\tt ftpmail}}
{\tt ftpmail} is a service which allows you to obtain files from FTP
archive sites via Internet electronic mail. If you don't have direct
Internet access, but are able to send mail to the Internet (from a service
such as CompuServe, for example), {\tt ftpmail} is a good way to get
files from FTP archive sites. Unfortunately, {\tt ftpmail} can be
slow, especially when sending large jobs. Before attempting to download
large amounts of software using {\tt ftpmail}, be sure that your 
mail spool will be able to handle the incoming traffic. Many systems
keep quotas on incoming electronic mail, and may delete your account
if your mail exceeds this quota. Just use common sense. 

{\tt sunsite.unc.edu}, one of the major Linux FTP archive sites, 
is home to an {\tt ftpmail} server. To use this service, send
electronic mail to
\begin{tscreen}
ftpmail@sunsite.unc.edu
\end{tscreen}
with a message body containing only the word:
\begin{tscreen}
help
\end{tscreen}
This will send you back a list of {\tt ftpmail} commands and a brief
tutorial on using the system. 

For example, to get a listing of Linux
files found on {\tt sunsite.unc.edu}, send mail to the above address
containing the text
\begin{tscreen}
open sunsite.unc.edu \\
cd /pub/Linux \\
dir \\
quit
\end{tscreen}

You may use the {\tt ftpmail} service to connect to any FTP archive
site; you are not limited to {\tt sunsite.unc.edu}. The next section lists 
a number of Linux FTP archives. 

\section{Linux FTP Site List}
\index{FTP!archive site list}
Table~\ref{table-ftp-sites} is a listing of the most well-known FTP archive 
sites which carry
the Linux software. Keep in mind that many other sites mirror these, and
more than likely you'll run into Linux on a number of sites not on this
list. 

\begin{table}[ht]\begin{center}
\small\begin{tabular}{lll} 
\hline
Site name                            &  IP Address      & Directory \\ 
\hline
tsx-11.mit.edu                       &  18.172.1.2      & /pub/linux \\
sunsite.unc.edu                      &  152.2.22.81     & /pub/Linux \\
nic.funet.fi                         &  128.214.6.100   & /pub/OS/Linux \\
ftp.mcc.ac.uk                        &  130.88.200.7    & /pub/linux \\
fgb1.fgb.mw.tu-muenchen.de           &  129.187.200.1   & /pub/linux \\
ftp.informatik.tu-muenchen.de        &  131.159.0.110   & /pub/Linux \\
ftp.dfv.rwth-aachen.de               &  137.226.4.105   & /pub/linux \\
ftp.informatik.rwth-aachen.de        &  137.226.112.172 & /pub/Linux \\
ftp.ibp.fr                           &  132.227.60.2    & /pub/linux \\
kirk.bu.oz.au                        &  131.244.1.1     & /pub/OS/Linux \\
ftp.uu.net                           &  137.39.1.9      & /systems/unix/linux \\
wuarchive.wustl.edu                  &  128.252.135.4   & /systems/linux \\
ftp.win.tue.nl                       &  131.155.70.100  & /pub/linux \\
ftp.ibr.cs.tu-bs.de                  &  134.169.34.15   & /pub/os/linux \\
ftp.denet.dk                         &  129.142.6.74    & /pub/OS/linux \\
\end{tabular}\normalsize\rm
\caption{Linux FTP Sites}
\label{table-ftp-sites}
\end{center}\end{table}

{\tt tsx-11.mit.edu}, {\tt sunsite.unc.edu}, and {\tt nic.funet.fi} are
the ``home sites'' for the Linux software, where most of the new software
is uploaded. Most of the other sites on the list mirror some combination of
these three. To reduce network traffic, choose a site that is geographically
closest to you.

\index{FTP!using|)}
