📄 787-789.html
字号:
<HTML>
<HEAD>
<TITLE>Linux Unleashed, Third Edition:Setting Up an FTP and Anonymous FTP Site</TITLE>
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<!--ISBN=0672313723//-->
<!--TITLE=Linux Unleashed, Third Edition//-->
<!--AUTHOR=Tim Parker//-->
<!--PUBLISHER=Macmillan Computer Publishing//-->
<!--IMPRINT=Sams//-->
<!--CHAPTER=48//-->
<!--PAGES=787-789//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="784-787.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="789-791.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<P>For most versions, FTP commands are case sensitive, and using uppercase will display error messages. Some versions perform a translation for you, so it doesn’t matter which case you use. Because Linux uses lowercase as its primary character set for everything else, you should probably use lowercase with all versions of FTP, too.
</P>
<H4 ALIGN="LEFT"><A NAME="Heading4"></A><FONT COLOR="#000077">How FTP Uses TCP</FONT></H4>
<P>The File Transfer Protocol uses two TCP channels: TCP port 20 is used for data and port 21 is for commands. Both these channels must be enabled on your Linux system for FTP to function. The use of two channels makes FTP different from most other file transfer programs. By using two channels, TCP allows simultaneous transfer of FTP commands and data. FTP works in the foreground and does not use spoolers or queues.
</P>
<P>FTP uses a server daemon that runs continuously and a separate program that is executed on the client. On Linux systems, the server daemon is called <TT>ftpd</TT>. The client program is <TT>ftp</TT>.</P>
<P>During the establishment of a connection between a client and server, and whenever a user issues a command to FTP, the two machines transfer a series of commands. These commands are exclusive to FTP and are known as the internal protocol. FTP’s internal protocol commands are four-character ASCII sequences terminated by a new-line character, some of which require parameters. One primary advantage of using ASCII characters for commands is that users can observe the command flow and understand it easily. This helps in a debugging process. Also, the ASCII commands can be used directly by a knowledgeable user to communicate with the FTP server component without invoking the client portion (in other words, communicating with <TT>ftpd</TT> without using <TT>ftp</TT> on a local machine), although this is seldom used except when debugging (or showing off).</P>
<P>After logging into a remote machine using FTP, you are not actually on the remote machine. You are still logically on the client, so all instructions for file transfers and directory movement must be with respect to your local machine and not the remote one. The process followed by FTP when a connection is established is:</P>
<DL>
<DD><B>1.</B> Login—Verify user ID and password
<DD><B>2.</B> Define directory—Identify the starting directory
<DD><B>3.</B> Define file transfer mode—Define the type of transfer
<DD><B>4.</B> Start data transfer—Allow user commands
<DD><B>5.</B> Stop data transfer—Close the connection
</DL>
<P>These steps are performed in sequence for each connection.
</P>
<P>A debugging option is available from the FTP command line by adding <TT>-d</TT> to the command. This displays the command channel instructions. Instructions from the client are shown with an arrow as the first character, while instructions from the server have three digits in front of them. A <TT>PORT</TT> in the command line indicates the address of the data channel on which the client is waiting for the server’s reply. If no <TT>PORT</TT> is specified, channel 20 (the default value) is used. Unfortunately, the progress of data transfers cannot be followed in the debugging mode. A sample session with the debug option enabled is shown here:</P>
<!-- CODE //-->
<PRE>
$ ftp -d tpci_hpws4
Connected to tpci_hpws4.
220 tpci_hpws4 FTP server (Version 1.7.109.2
åTue Jul 28 23:32:34 GMT 1992) ready.
Name (tpci_hpws4:tparker):
---> USER tparker
331 Password required for tparker.
Password:
---> PASS qwerty5
230 User tparker logged in.
---> SYST
215 UNIX Type: L8
Remote system type is UNIX.
---> Type I
200 Type set to I.
Using binary mode to transfer files.
ftp> ls
---> PORT 54,80,10,28,4,175
200 PORT command successful.
---> TYPE A
200 Type set to A.
---> LIST
150 Opening ASCII mode data connection for /bin/ls.
total 4
-rw-r----- 1 tparker tpci 2803 Apr 29 10:46 file1
-rw-rw-r-- 1 tparker tpci 1286 Apr 14 10:46 file5_draft
-rwxr----- 2 tparker tpci 15635 Mar 14 23:23 test_comp_1
-rw-r----- 1 tparker tpci 52 Apr 22 12:19 xyzzy
Transfer complete.
---> TYPE I
200 Type set to I.
ftp> <Ctrl-d>
$
</PRE>
<!-- END CODE //-->
<P>You may have noticed in the preceding listing how the mode changed from binary to ASCII in order to send the directory listing, and then back to binary (the system default value).
</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="784-787.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="789-791.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -