rhl47.htm

来自「linux的初学电子书」· HTM 代码 · 共 1,210 行 · 第 1/3 页

HTM
1,210
字号
<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

close

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Terminates the connection</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

del

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Deletes a file on the server</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

dir

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Displays the server directory</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

get

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Fetches a file from the server</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

hash

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Displays a pound character for each block transmitted</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

help

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Displays help</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

lcd

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Changes directory on the client</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

mget

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Fetches several files from the server</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

mput

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Sends several files to the server</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

open

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Connects to a server</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

put

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Sends a file to the server</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

pwd

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Displays the current server directory</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

quote

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Supplies an FTP command directly</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

quit

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Terminates the FTP session</FONT>

</TABLE><P>For most versions, FTP commands are case sensitive, and using upper case will display error messages. Some versions perform a translation for you, so it doesn't matter which case you use. Since Linux uses lower case as its primary character set 
for everything else, you should probably use lower case with all versions of FTP, too.

<BR>

<BR>

<A NAME="E69E498"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>How FTP Uses TCP</B></FONT></CENTER></H4>

<BR>

<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.

<BR>

<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 ftpd. The client program is ftp.

<BR>

<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 ftpd without using ftp on a local 
machine); this is seldom used except when debugging (or showing off).

<BR>

<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:

<BR>

<OL>

<LI>Login&#151;Verify user ID and password

<BR>

<BR>

<LI>Define directory&#151;Identify the starting directory

<BR>

<BR>

<LI>Define file transfer mode&#151;Define the type of transfer

<BR>

<BR>

<LI>Start data transfer&#151;Allow user commands

<BR>

<BR>

<LI>Stop data transfer&#151;Close the connection

<BR>

<BR>

</OL>

<P>These steps are performed in sequence for each connection.

<BR>

<P>A debugging option is available from the FTP command line by adding -d 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 PORT in the command line indicates the address of the data channel on which the client is waiting for the server's reply. If no PORT 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:

<BR>

<PRE>

<FONT COLOR="#000080">$ 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):

&#151;&gt; USER tparker

331 Password required for tparker.

Password:

&#151;&gt; PASS qwerty5

230 User tparker logged in.

&#151;&gt; SYST

215 UNIX Type: L8

Remote system type is UNIX.

&#151;&gt; Type I

200 Type set to I.

Using binary mode to transfer files.

ftp&gt; ls

&#151;&gt; PORT 47,80,10,28,4,175

200 PORT command successful.

&#151;&gt; TYPE A

200 Type set to A.

&#151;&gt; LIST

150 Opening ASCII mode data connection for /bin/ls.

total 4

-rw-r&#151;&#151; 1 tparker tpci 2803 Apr 29 10:46 file1

-rw-rw-r&#151; 1 tparker tpci 1286 Apr 14 10:46 file5_draft

-rwxr&#151;&#151; 2 tparker tpci 15635 Mar 14 23:23 test_comp_1

-rw-r&#151;&#151; 1 tparker tpci 52 Apr 22 12:19 xyzzy

Transfer complete.

&#151;&gt; TYPE I

200 Type set to I.

ftp&gt; &lt;Ctrl-d&gt;

$</FONT></PRE>

<P>You may have noticed in the preceding listing how the mode changed from binary to ASCII to send the directory listing, and then back to binary (the system default value).

<BR>

<BR>

<A NAME="E68E377"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>Configuring FTP</B></FONT></CENTER></H3>

<BR>

<P>Whether you decide to provide an anonymous FTP site or a user-login FTP system, you need to perform some basic configuration steps to get the FTP daemon active and get the directory system and file permissions properly set to prevent users from 
destroying or accessing files they shouldn't. The process can start with choosing an FTP site name. You don't really need a site name, although it can be easier for others to access your machine with one (especially anonymously). The FTP site name is of 
the format:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">ftp.domain_name.domain_type</FONT></PRE>

<P>where domain_name is the domain name (or an alias) of the FTP server's domain, and domain_type is the usual DNS extension. For example, you could have an FTP site name of

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">ftp.tpci.com</FONT></PRE>

<P>showing that this is the anonymous FTP access for anyone accessing the tpci.com domain. It is usually a bad idea to name your FTP site with a specific machine name, such as:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">ftp.merlin.tpci.com</FONT></PRE>

<P>because this makes it difficult to move the FTP server to another machine in the future. Instead, use an alias to point to the actual machine on which the FTP server sits. This is not a problem if you are a single machine connected to the Internet 
through a service provider, for example, but it is often necessary with a larger network. The alias is easy to set up if you use DNS. Set the alias in the DNS databases with a line like this:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">ftp IN CNAME merlin.tpci.com</FONT></PRE>

<P>This line points anyone accessing the machine ftp.tpci.com to the real machine merlin.tpci.com. If the machine merlin has to be taken out of its FTP server role for any reason, a change in the machine name on this line will point the ftp.tpci.com access 
to the new server. (A change in the alias performed over DNS can take a while to become active because the change must be propagated through all the DNS databases.)

<BR>

<BR>

<A NAME="E69E499"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Setting Up </B><B>ftpd</B></FONT></CENTER></H4>

<BR>

<P>The FTP daemon, ftpd, must be started on the FTP server. The daemon is usually handled by inetd instead of the rc startup files, so ftpd is only active when someone needs it. This is the best approach for all but the most heavily loaded FTP sites. When 
started using inetd, the inetd daemon watches the TCP command port (channel 21) for an arriving data packet requesting a connection, and then spawns ftpd.

<BR>

<P>Make sure the ftpd daemon can be started by inetd by checking the inetd configuration file (usually /etc/inetd.config or /etc/inetd.conf) for a line that looks like this:

<BR>

<BR>

<PRE>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?