📄 ch14.htm
字号:
a sample FTP session and follow the steps for finding and getting software from a
remote site.</P>
<P><TT>ftp</TT> is the user interface to the ARPANET standard FTP. The <TT>ftp</TT>
service is the interface to the file transfer protocol. It lets a user connect to
another site and send and receive files.</P>
<P>In this section you will try to get a file from the address <TT>tsx-11.mit.edu</TT>
by logging in as anonymous. This anonymous use of FTP is very convenient and provides
access to innumerable servers, providing a wealth of information. Publicly accessible
FTP servers are called anonymous FTP servers.
<CENTER>
<H4><A NAME="Heading38<FONT COLOR="#000077">Anonymous FTP</FONT></H4>
</CENTER>
<P>Anonymous FTP enables users to access remote sites without having an authorized
user ID and password. Generally the login ID is <TT>anonymous</TT> and the password
is <TT>guest</TT>. Most current systems require your e-mail address as the password
instead of <TT>guest</TT>.
<DL>
<DT></DT>
</DL>
<DL>
<DD>
<HR>
<A NAME="Heading39<FONT COLOR="#000077"><B>TIP:</B> </FONT>FTP stands for File
Transfer Protocol; <TT>ftp</TT> is the program you run on Linux.
<HR>
</DL>
<P>The client host with which <TT>ftp</TT> is to communicate may be specified on
the command line. If this is done, <TT>ftp</TT> immediately attempts to establish
a connection to an FTP server on that host. Otherwise, <TT>ftp</TT> enters its command
interpreter and awaits instructions from the user. When <TT>ftp</TT> is awaiting
commands from the user, the prompt <TT>ftp></TT> is provided to the user. Enter
<TT>ftp</TT> at the prompt, along with the site address:<FONT COLOR="#0066FF"></FONT>
<PRE><FONT COLOR="#0066FF">$ ftp hostname
</FONT></PRE>
<P>A hostname can be either a hostname or an Internet address. For example, you can
use the following Internet address:<FONT COLOR="#0066FF"></FONT>
<PRE><FONT COLOR="#0066FF">mpsi$ ftp tsx-11.mit.edu
</FONT></PRE>
<P>If your system connects to the MIT server, the text shown in Listing 14.10 appears.
<CENTER>
<H3><A NAME="Heading40<FONT COLOR="#000077">Listing 14.10. An ftp session.</FONT></H3>
</CENTER>
<PRE><FONT COLOR="#0066FF">
220 tsx-11 FTP server (Version wu-2.4(3) Mon Jun 5 16:40:22 EDT 1995) ready.
Name (tsx-11.mit.edu:uzma): anonymous
331 Guest login ok, send your complete e-mail address as password.
Password:
230-Welcome, archive user! This is an experimental FTP server. If you have any
230-unusual problems, please report them via e-mail to ftp-bugs@tsx-11.mit.edu.
230-If you do have problems, please try using a dash (-) as the first character
230-of your password -- this will turn off the continuation messages that may
230-be confusing your ftp client.
230-
230-The Linux archives are in /pub/linux/
230-
230-In most places, `get <directory>.tar' will retrieve a tar file containing
230-that directory. `get <file>.gz' gets a gzipped version of the files, and
230-`get <file>.Z' gets a compressed version of the file. `get <dir>.tar.gz'
230-is possible, but not recommended. `get <dir>.zip' will get a zip archive
230-with *NO* compression of the directory <dir>.
230-
230-If you find something on TSX-11 which doesn't work, or which you
230-believe is obsolete, please send mail to ftp-linux@TSX-11.MIT.EDU.
230-INCLUDE THE FULL PATHNAME OF THE FILE AND WHY YOU THINK IT IS OBSOLETE.
230-
230- - Ted and Michael
230-
230 Guest login ok, access restrictions apply.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>
</FONT></PRE>
<P>The first line confirms that the connection is established. Line 220 indicates
that the FTP server is ready. The system then prompts for a name, which is <TT>anonymous</TT>
in this case, and a password. The password is not echoed, so any typing mistakes
you make are not apparent. You are then connected to the remote FTP server, which
awaits your commands. ftp Commands The <TT>ftp</TT> service enables the user to execute
several commands. Some of the local commands are listed in Table 14.3. <BR>
<CENTER>
<P><FONT SIZE="4">Table 14.3. Some ftp commands. </FONT>
<TABLE BORDER="0">
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><I>Command </I></TD>
<TD ALIGN="LEFT"><I>Description </I></TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>[account [</TT>passwd<TT>]]</TT> </TD>
<TD ALIGN="LEFT">Provides a supplemental password required by a remote system for access to resources
once a login has been successfully completed. If no argument is included, the user
is prompted for an account password in a non-echoing input mode. </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>ascii</TT> </TD>
<TD ALIGN="LEFT">Sets the file transfer type to network ASCII. This is the default type. </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>bell</TT> </TD>
<TD ALIGN="LEFT">Sounds a bell after each file transfer. </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>binary</TT> </TD>
<TD ALIGN="LEFT">Sets the file transfer type to binary mode. </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>bye</TT> </TD>
<TD ALIGN="LEFT">Terminates the FTP session with the remote server and then exits. </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>cd </TT>remote-directory </TD>
<TD ALIGN="LEFT">Changes the working directory on the remote machine to the remote directory. </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>cdup</TT> </TD>
<TD ALIGN="LEFT">Goes to the parent of the current remote machine's working directory. </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>chmod </TT>mode file-name </TD>
<TD ALIGN="LEFT">Changes the permission modes of the file. </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>close</TT> </TD>
<TD ALIGN="LEFT">Terminates the FTP session with the remote server. </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>delete </TT>remote-file </TD>
<TD ALIGN="LEFT">Deletes the remote file on the remote machine. </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>dir [</TT>remote-directory<TT>]</TT> </TD>
<TD ALIGN="LEFT">Prints a listing of the remote directory to the terminal. </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>disconnect</TT> </TD>
<TD ALIGN="LEFT">Same as <TT>close</TT>. </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>get </TT>remote-file </TD>
<TD ALIGN="LEFT">Retrieves the remote file and stores it on the local ma- </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>[</TT>local-file<TT>]</TT> </TD>
<TD ALIGN="LEFT">chine. If the local filename is not specified, it is given the same name it </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"> <P>
</TD>
<TD ALIGN="LEFT">has on the remote machine. </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>hash</TT> </TD>
<TD ALIGN="LEFT">While a file is being transferred, the hash sign (#) is printed for each data block
transferred. </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>help [</TT>command<TT>]</TT> </TD>
<TD ALIGN="LEFT">Prints an informative message about the meaning of the command. If no argument is
given, <TT>ftp</TT> prints a list of the known commands. </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>lcd [</TT>directory<TT>]</TT> </TD>
<TD ALIGN="LEFT">Changes the working directory on the local machine. If no directory is specified,
the user's home directory is used. </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>ls [</TT>remote-directory<TT>]</TT> </TD>
<TD ALIGN="LEFT">Lists the contents of the remote directory. </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>mdelete [</TT>remote-files<TT>]</TT> </TD>
<TD ALIGN="LEFT">Deletes the remote files on the remote machine. </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>mdir </TT>remote-files </TD>
<TD ALIGN="LEFT">Like <TT>dir</TT>, except multiple remote files may be specified. </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>mget </TT>remote-files </TD>
<TD ALIGN="LEFT">Expands the remote files on the remote machine and does a <TT>getfiles</TT> based
on regular expressions. For example, <TT>mget f*.tar</TT> will get all the files
starting with the letter f. </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>open </TT>host<TT> [</TT>port<TT>]</TT> </TD>
<TD ALIGN="LEFT">Establishes a connection to the specified host FTP server on the optional port number.
</TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>put </TT>local-file </TD>
<TD ALIGN="LEFT">Stores a local file on the remote machine. </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>pwd</TT> </TD>
<TD ALIGN="LEFT">Prints the name of the current working directory on the remote machine. </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>quit</TT> </TD>
<TD ALIGN="LEFT">Same as <TT>bye</TT>. </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>remotehelp [</TT>command-name<TT>]</TT> </TD>
<TD ALIGN="LEFT">Requests help from the remote FTP server. If a command name is specified, it is supplied
to the server as well. </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>reset</TT> </TD>
<TD ALIGN="LEFT">Resets the communications connection. </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>rmdir </TT>directory-name </TD>
<TD ALIGN="LEFT">Deletes a directory on the remote machine. </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>size </TT>file-name </TD>
<TD ALIGN="LEFT">Returns the size of the file on the remote machine. </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>status</TT> </TD>
<TD ALIGN="LEFT">Shows the current status of <TT>ftp</TT>. </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>verbose</TT> </TD>
<TD ALIGN="LEFT">Displays all responses to the user. </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><TT>? [</TT>command<TT>]</TT> </TD>
<TD ALIGN="LEFT">Same as <TT>help</TT>. </TD>
</TR>
</TABLE>
Here are some of the options that may be specified at the command line:
<TABLE BORDER="0">
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="70" ALIGN="LEFT"><TT>-v</TT> </TD>
<TD ALIGN="LEFT">The verbose option. Gives a report on the transfer statistics and forces <TT>ftp</TT>
to show all responses from the remote server. <BR>
</TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="70" ALIGN="LEFT"> </TD>
<TD ALIGN="LEFT"> </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="70" ALIGN="LEFT"><TT>-n</TT> </TD>
<TD ALIGN="LEFT">Restrains <TT>ftp</TT> from attempting auto-login upon initial connection. In auto-login,
<TT>ftp</TT> checks for </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="70" ALIGN="LEFT"> <P>
</TD>
<TD ALIGN="LEFT">the user's account on the remote machine. </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="70" ALIGN="LEFT"><TT>-I</TT> </TD>
<TD ALIGN="LEFT">Turns off interactive prompting during multiple file transfers. </TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD WIDTH="70" ALIGN="LEFT"><TT>-d<BR>
</TT></TD>
<TD ALIGN="LEFT">Enables debugging.<BR>
</TD>
</TR>
</TABLE>
Some <TT>ftp</TT> commands share the same name as Linux comman
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -