One of the greatest incentives for using the Internet is the ability to
download files from other computers connected to the Net. The most common
way to get these files is by using ftp, the Internet File Transfer Protocol.
ftp is a command like any other; you invoke it by either typing it in at the command prompt or clicking on an icon
(you should really be using something like
filezilla. It's got everything to need to use ftp).
The ftp command expects an argument telling it the address of the computer you want to connect to.
This address can be either a known host name , a Fully Qualified Domain Name (FQDN) or an Internet Protocol (IP) numeric address; ftp doesn't care which form you use as long as it points to a legitimate host. If you don't supply the host argument when you invoke ftp, you will have to use the open command after ftp is started, so it's usually easier to specify the host when ftp is first started.
Once ftp is invoked and is given a host name, it will attempt to contact that host. When the remote host is contacted it responds by displaying a login prompt. Most hosts on the Internet accept the login name, anonymous . This is a special account the remote hosts use just for ftp connections over the Internet to let anyone connect, view and download files. This kind of connection is called, anonymous ftp, and is provided (it
used to be anyway) as a courtesy to anyone having Net access.
After the login, ftp will prompt for a password, this is usually your e-mail address. Once logged in, you will be in a directory that the remote host has reserved exclusively for ftp . Most ftp hosts keep the files available for download in a directory called, pub (most web hosting services use public_html for their clients), so change to that directory:
cd pub
To list the files in the directory, use either the UNIX/Linux ls command or the MS-DOS command, dir . The ls command accepts the -C option for a columnar listing while the dir command shows more about the files (size. etc.). If you want to download executable files (programs, ZIP files, formatted text files from a word processor or graphics), you have to tell ftp to send the files in binary , so type,
binary
To keep ftp from prompting for confirmation for each file downloaded,
prompt
To download more than one file at a time, use wildcards to specify multiple files and then type
mget
to download those files. To download all the ZIP files that begin with the letter K, for instance ...
mget K*.zip
To exit ftp type,
quit
Notice that file names on most ftp hosts are case sensitive - the host can tell the difference between k and K and treat them as different characters.
Using Macros and the .netrc file
In UNIX/Linux you can add a .netrc file in your HOME directory and completely automate
ftp sessions. Use vi or some other plain-text editor ad create the .netrc file in your
HOME directory (you have to prefix the file name with the dot (.) or it won't work).
The vi session might look like this (enter the commands in bold):
cd
vi .netrc
a
machine acme.generic.com login plasbo password harledoo
Hit the Esc key here ...
:wq!
That's it. That logs you in whenever you type,
ftp acme.generic.com
You can do even more though using macros:
cd
vi .netrc
:$
a
macdef uploadtest
machine acme.generic.com login churley password desmonda
cd /pub/tests/bin
put filename.tar.gz
quit
macdef dailyupload
machine excelsior.motel.com login ugly password raton
cd /public_html
prompt
binary
mget *tar.gz
quit
macdef default
machine wanker.fluftie.net login hacz password lollyDoo192
cd /var/log
get messages
quit
Hit the Esc key here ...
:wq!
The macdef lines are the ftp sites you can login into using .netrc that also will cd
into the directory you want and then run some ftp commands and then logout (quit). Put
a least one blank line after a macdef definition or it won't work right. The last
macdef is default. If you don't specify an ftp site, this is where you'll end
up. You can also just have the .netrc simply log you in and issue commands yourself.
While you will probably never use ftp this way (you've got filezilla, right?) it's
always good to know what's under the hood. For more on archiving, Click Here
A Note About Terminology
(Even more detail can be found Here)
As with most things related to computers, the terms used in reference to the Internet must be understood in order to make good use of the medium. A host is a computer. Each host on a network has a unique "name", most often referred to as its address .
On the Internet this address conforms to a set of rules called the Internet Protocol or IP and can be either a name (DNS) in the form, host.organization.domain or a numeric notation called dotted decimal like this
192.128.21.30
In both forms, the address refers to the same computer, the only significant difference is that the first form is somewhat easier to remember. These two forms of addressing remote hosts are not really equivalent. The numeric, dotted decimal, form will always work while the alphabetic form depends on a layer of software called Domain Name Service (DNS). The DNS software is run on a computer to resolve the alphabetic form of an address into a numeric IP address. If the DNS computer is down or not on line, DNS can't be used and you can only use the IP address.
The addressing in the IP format is composed of four fields called octets, separated by a period (dot). The host is found in the rightmost octet. In the IP address 192.128.21.30, the host is 30 in sub-network 21 in network 192.128. Addressing in alphabetic form reads in the opposite direction: host.organization.domain, where the host is the left- most part of the address To add a host to the Internet, it must be registered with InterNIC (Network Information Center) which assigns an address within one of four classes (A-D with class D reserved).
This registration is really for a network (usually quite large). Once the registered address has been assigned, the network administrators can divide the address space among other networks using sub-nets . An individual host computer is located on one of these sub-nets. To locate a computer on the Internet, you must first know the NIC assigned address and then the sub-net the host is physically connected to and, finally, the address of that host on the sub-net.
This is how the IP address of a particular host is represented and why the dotted decimal format is used to separate different pieces of information about an address. Domain Name Service (DNS) is software having the sole purpose of translating the dotted decimal IP addressing format into a more easily remembered names. The name sales.acme.com , for instance, is considerably more mnemonic than 133.23.45.12 is it not?
What this all means is that you always reach a computer using its IP address
even when the DNS software is disabled or flakey. If you have the ability
to save host addresses, the safest and surest way to reach those hosts is
to use the IP address assigning a label (name) or icon to the hosts using their IP
address whenever possible (see environment variables and aliases).
While ftp is most often used to get files from a remote computer on the Internet, it is also very useful within a local network ( LAN or Intranet). This capability is especially handy if you have a variety of computers in the local network, some of which are incompatible with the others. Within your local network, you can use ftp to upload files from one computer to another and then download them to yet another local computer. By shuffling files around this way, you by-pass the compatibility problems. Since it's common to use UNIX/Linux based computers as servers on a network through which mail and other services are made available, it's also possible to have a login account on the UNIX/Linux machine
(see this ).
Invoke ftp and give it the host name or IP address by which the UNIX/Linux machine is known on the local network. Once ftp connects to the UNIX/Linux machine, it will prompt for a login. This time you won't be logging in anonymously. Instead you need to enter your login name for the UNIX/Linux account and then your password. ftp will deposit you in your home directory for the UNIX/Linux account. From here you will use ftp the same as if you had accessed a computer on the Internet. except that you will be viewing and copying files to and from your UNIX/Linux account.
You can also create aliases to execute a command with whatever arguments you want to give it,
alias msoft='ftp ftp://microsoft.com'
Then just type the alias name and the whole ftp command executes. There are lots of other neat things you can do with your UNIX/Linux account but, unfortunately, you have to be willing to learn UNIX/Linux and one of the numerous shells it offers and this, alas, takes considerable effort over several years. You can also use the Web to ftp files if you know the ftp site name
(while you fetch web pages using http://, you get to ftp sites by entering, ftp://).
Notice that on the top of your Web browser, there's a horizontal window showing the net address of the current document. This window shows the full path to the site where the document is located as well as the document's name. If you're viewing a Web page the document name will end with the letters, html or htm; this is the way the Web browser identifies the document type so that it can properly display it.
This kind of information is at the end of the full site path name at the right of the site address window. At the beginning of the path (at the left end of the window) is another kind of identifier that tells the Web browser the kind of site the document is on. Most of the time this identifier is, http:// and means that this site uses the Hyper Text Transfer Protocol (HTTP;
it's a web server). There are other identifiers though. You can highlight the text string, http and type ftp in its place since many of the sites have files that are available for ftp downloading.
Once your browser finds the site, a list of files and directories will display. Click to change into one of the directories and double-click to download a file. The files will end up in the download directory you specified when you set the options within your browser
(ftp will generally put files in either the current directory or the directory where
the ftp command was started). Once you've finished with that site, you can repeat the process to download from other sites. Most Web sites support ftp so you can leave the ftp portion of the address unchanged and just type in the site name. Web sites generally follow the addressing form of the organization name followed by the organization type, like this, nasa.gov
Here nasa is the name of the organization and also the actual site name. The gov portion of the site address is identifies the type of organizational domain that nasa belongs to, in this case, government. There are several other organizational types including, gov Government, mil Military, edu Educational, org Organization (usually non-profit), net Network Service Provider, com Corporate Try some of the following using ftp.
ftp://microsoft.com
ftp://java.sun.com
ftp://ftp.ora.com
ftp://rtfm.mit.edu
Remember that if you're using your Web browser and have it already displaying the path to the site having files you want to download, just replace the http part of its address with ftp and hit Enter . At most sites this will transfer you directly to their ftp archives.
This isn't as common as it was a few years ago, but lots of sites still allow ftp
access.