-->
Previous | Table of Contents | Next |
Linux also features ftp, a command that allows you to link directly to another computer using the network TCP/IP. Essentially, if you have a TCP/IP connection to the Internet, you can use ftp to connect to any public site on the Net. In this section, well guide you through an FTP session.
The ftp command can be used to connect to any other computer on your network running ftp. If your system is connected to the Internet, you can use ftp to access files from other Internet computers worldwide. The machines with which you network may or may not be running the UNIX or Linux operating systems; this operating-system independence is what makes FTP so widely used.
FTP is interactive software, which means it asks for information at specific times. Start it with the following:
gilbert:/$ ftp ftp>
Youll be presented with the ftp prompt, where you enter special ftp commands. To get a list of available commands, type a question mark (?) or help at the prompt:
ftp> ? or ftp> help
A list of the most common FTP commands is contained in Table 9.3.
Command | Result |
---|---|
ascii | Use ASCII as the file-transfer type. |
bell | Ring the bell when file transfer is complete. |
binary | Use binary as the file-transfer type. |
bye or quit | Terminate ftp session. |
cd | Change directory on the remote machine. |
close | End ftp connection to remote computer but keep local ftp program running. |
delete filename | Delete filename on remote computer. |
get filename | Get filename from the remote machine. |
get filename1 filename2 | Get filename1 from the remote machine and save it locally as filename2. |
help | List available commands. |
mput filename | Copy the local filename to the remote machine. |
pwd | List the current directory on the remote machine. |
Its simple to download files from a remote machine with ftp. Lets say we want to grab some files from the machine named mn.kevin.com. (No, this isnt a real machine.) Assuming that this is a machine on the Internet that supports anonymous FTPand our fictional machine does, of courseyou would merely specify its name on the command line:
gilbert:/$ ftp mn.kevin.com
If the connection goes through, youll receive a verification message, along with a login prompt. Because this is anonymous FTP, use anonymous as a login name:
Name: anonymous
Youll then be asked for a password. Some systems require you to supply your electronic-mail address, while others require guest. Use either. Youll then be presented with an ftp prompt.
The remote system has been set up to give you limited access, which means that your maneuverability is very limited and the files you want are usually close at hand. If you need to change to another directory, do so with the UNIX cd command.
Before embarking on the great file quest, you should know something about the files youre downloading. If they are straight C files in uncompressed, ASCII form, you can download them using the default file-transfer settings. Most larger files, especially binary files, are stored in compressed form so they take less time to transfer.
These compressed files end with .Z, .z, .tgz, .zip, or .gz. so they are instantly recognizable. To download compressed files, you must change to binary mode, because youre downloading binary files. Do so with:
ftp> binary
Once you are placed in the correct directory containing the file to be downloaded, start the download process with the get command:
ftp> get filename
As you download the file, there will be a prompt on the system, and you wont be able to enter any keystrokes.
After the file has been transferred successfully, youll be given a message similar to the following:
Transfer complete
You may also be told the size of the file and the transfer time.
Because youre through with your file needs, close the connection with the bye command:
ftp> bye
If you download an ASCII file, you can view it using any editor, including vi or emacs. If its a sourcecode file, you can compile it for use on your own system; we explain the process in Chapter 10. If youve downloaded a compressed binary file, you will have to uncompress it (and perhaps unarchive it) at the command line using uncompress, unpack, tar, or gzipthings you learned about in Chapter 4.
Previous | Table of Contents | Next |