rhl47.htm

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

HTM
1,210
字号
<HTML>

<HEAD>

<TITLE>Red Hat Linux Unleashed rhl47.htm </TITLE>

<LINK REL="ToC" HREF="index-1.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/index.htm">

<LINK REL="Index" HREF="htindex.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/htindex.htm">

<LINK REL="Next" HREF="rhl48.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl48.htm">

<LINK REL="Previous" HREF="rhl46.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl46.htm"></HEAD>

<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080">

<A NAME="I0"></A>

<H2>Red Hat Linux Unleashed rhl47.htm</H2>

<P ALIGN=LEFT>

<A HREF="rhl46.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl46.htm" TARGET="_self"><IMG SRC="purprev.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purprev.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Previous Page"></A>

<A HREF="index-1.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/index.htm" TARGET="_self"><IMG SRC="purtoc.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purtoc.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="TOC"></A>

<A HREF="rhl48.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl48.htm" TARGET="_self"><IMG SRC="purnext.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purnext.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Next Page"></A>


<HR ALIGN=CENTER>

<P>

<UL>

<UL>

<UL>

<LI>

<A HREF="#E68E376" >What Is FTP?</A>

<UL>

<LI>

<A HREF="#E69E497" >Using FTP</A>

<LI>

<A HREF="#E69E498" >How FTP Uses TCP</A></UL>

<LI>

<A HREF="#E68E377" >Configuring FTP</A>

<UL>

<LI>

<A HREF="#E69E499" >Setting Up ftpd</A>

<LI>

<A HREF="#E69E500" >FTP Logins</A>

<LI>

<A HREF="#E69E501" >Setting Up the Directories</A>

<LI>

<A HREF="#E69E502" >Setting Permissions</A>

<LI>

<A HREF="#E69E503" >Test the System</A></UL>

<LI>

<A HREF="#E68E378" >A More Secure FTP</A>

<LI>

<A HREF="#E68E379" >Summary</A>

<UL>

<LI>

<A HREF="#E69E504" >Checklist Protecting an Anonymous FTP System</A></UL></UL></UL></UL>

<HR ALIGN=CENTER>

<A NAME="E66E47"></A>

<H1 ALIGN=CENTER>

<CENTER>

<FONT SIZE=6 COLOR="#FF0000"><B>47</B></FONT></CENTER></H1>

<BR>

<A NAME="E67E47"></A>

<H2 ALIGN=CENTER>

<CENTER>

<FONT SIZE=6 COLOR="#FF0000"><B>Setting Up an FTP and Anonymous FTP Site</B></FONT></CENTER></H2>

<BR>

<P>Snap question: What is the most widely used TCP/IP and Internet service? If you answered FTP, you're right. (If you didn't choose FTP, this may come as a bit of a surprise. The fact is, FTP remains the most widely used service; although the World Wide 
Web is quickly catching up.) FTP's popularity is easy to figure: The FTP software is supplied with every version of UNIX and Linux, it's easy to install, configure, and use, and it gives users access to a wealth of information with very little effort.

<BR>

<P>If all you want to use FTP for is connecting to another machine and transferring files, then you don't have to do much more than enable the FTP service on your system. Much more interesting to many users is turning your Linux machine into an FTP site, 
where others can connect and obtain files you make available. That's the primary focus of this chapter&#151;setting up an FTP site on your Linux machine. We'll begin, though, with a quick look at using FTP and the way FTP runs on TCP. This information 
should help you understand how FTP works and what it does with TCP/IP.

<BR>

<BR>

<A NAME="E68E376"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>What Is FTP?</B></FONT></CENTER></H3>

<BR>

<P>The File Transfer Protocol (FTP) is one protocol in the TCP/IP family used to transfer files between machines running TCP/IP. (FTP-like programs are also available for some other protocols.) The File Transfer Protocol allows you to transfer files back 
and forth and manage directories. FTP is not designed to allow you access to another machine to execute programs, but it is the best utility for file manipulation. To use FTP, both ends of a connection must be running a program that provides FTP services. 
The end that starts the connection (the client) calls the other end (the server) and establishes the FTP protocol through a set of handshaking instructions.

<BR>

<P>Usually, when you connect to a remote system via FTP, you must log in. This means you must be a valid user, with a user name and password for that remote machine. Because it is impossible to provide logins for everyone who wants to access a machine that 
enables anyone to gain access, many systems use &quot;anonymous FTP&quot; instead. Anonymous FTP enables anyone to log in to the system with the login name of &quot;ftp&quot; or &quot;anonymous&quot; with either no password, or an e-mail address for their 
local system.

<BR>

<BR>

<A NAME="E69E497"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Using FTP</B></FONT></CENTER></H4>

<BR>

<P>Using FTP to connect to a remote site is easy. You have access to the remote machine either through the Internet (directly or through a service provider) or through a local area network if the remote machine is directly reachable. To use FTP, you start 
the FTP client software and provide the name of the remote system you want to connect to. For example, assuming you can get to the remote machine through a LAN or the Internet (which knows about the remote machine thanks to Domain Name Service), you issue 
the following command:

<BR>

<BR>

<PRE>

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

<P>This will instruct your FTP software to try to connect to the remote machine chatton.com and establish an FTP session.

<BR>

<P>When the connection is completed (and assuming the remote system allows FTP logins), the remote will prompt for a user ID. If anonymous FTP is supported on the system, a message will usually tell you exactly that. The following is for the Linux FTP 
archive site sunsite.unc.edu:

<BR>

<PRE>

<FONT COLOR="#000080">ftp sunsite.unc.edu

331 Guest login ok, send your complete e-mail address as password.

Enter username (default: anonymous): anonymous

Enter password [tparker@tpci.com]:

|FTP| Open

230- WELCOME to UNC and SUN's anonymous ftp server

230- University of North Carolina

230- Office FOR Information Technology

230- SunSITE.unc.edu

230 Guest login ok, access restrictions apply.

FTP&gt;</FONT></PRE>

<P>After the login process is completed, you will see the prompt FTP&gt; indicating the remote system is ready to accept commands.

<BR>

<P>When you log on to some systems, you may see a short message that contains instructions for downloading files, any restrictions that are placed on you as an anonymous FTP user, or information about the location of useful files. For example, you may see 
messages like these (taken from the Linux FTP site):

<BR>

<PRE>

<FONT COLOR="#000080">To get a binary file, type: BINARY and then: GET &quot;File.Name&quot; newfilename

To get a text file, type: ASCII and then: GET &quot;File.Name&quot; newfilename

Names MUST match upper, lower case exactly. Use the &quot;quotes&quot; as shown.

To get a directory, type: DIR. To change directory, type: CD &quot;Dir.Name&quot;

To read a short text file, type: GET &quot;File.Name&quot; TT

For more, type HELP or see FAQ in gopher.

To quit, type EXIT or Control-Z.

230- If you email to info@sunsite.unc.edu you will be sent help information

230- about how to use the different services sunsite provides.

230- We use the Wuarchive experimental ftpd. if you &quot;get&quot; &lt;directory&gt;.tar.Z

230- or &lt;file&gt;.Z it will compress and/or tar it on the fly. Using &quot;.gz&quot; instead

230- of &quot;.Z&quot; will use the GNU zip (/pub/gnu/gzip*) instead, a superior

230- compression method.</FONT></PRE>

<P>Once you are logged on the remote system, you can use familiar Linux commands to display file contents and move around directories. To display the contents of a directory, for example, use the ls command (some systems support the DOS equivalent dir). To 
change to a subdirectory, use the cd command. To return to the parent directory (the one above the current directory), use the command cd ... As you can see, these commands are the same as you would use on your local machine, except you are now navigating 
on the remote system.

<BR>

<P>There are no keyboard shortcuts (such as pressing the Tab key to fill in names that match) available with FTP. This means you have to type in the name of files or directories in their entirety (and correctly). If you misspell a file or directory name, 
you will get error messages and have to try again. Luckily, if you are performing the FTP session through X Window, you can cut and paste lines from earlier in your session.

<BR>

<P>Transferring files is the whole point of FTP, so you need to know how to retrieve a file from the remote system, as well as how to put a new file there. When you have moved through the remote system's directories and have found a file you want to 
transfer back to your local system, use the get command. This is followed by the filename. For example:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">get &quot;soundcard_driver&quot;</FONT></PRE>

<P>This will transfer the file soundcard_driver from the remote machine to the current directory on your local machine. When you issue a get command, the remote system will transfer data to your local machine and display a status message when it is 
completed. There is no indication of progress when a large file is being transferred, so be patient. (Most versions of FTP allow you to use the hash option, which displays pound signs every time a kilobyte of information has been transferred. This can be 
used to show that the transfer is underway, but it doesn't offer a time to completion.)

<BR>

<PRE>

<FONT COLOR="#000080">FTP&gt; get &quot;file1.txt&quot;

200 PORT command successful.

150 BINARY data connection for FILE1.TXT (27534 bytes)

226 BINARY Transfer complete.

27534 bytes received in 2.35 seconds (12 Kbytes/s).</FONT></PRE>

<P>If you want to transfer a file the other way (from your machine to the remote, assuming you are allowed to write to the remote machine's file system), use the put command in the same way. The command:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">put &quot;comments&quot;</FONT></PRE>

<P>will transfer the file comments from your current directory on the local machine (you can specify full pathnames) to the current directory on the remote machine (unless you change the path).

<BR>

<P>The commands get (download) and put (upload) are always relative to your home machine. You are telling your system to get a file from the remote and put it on your local machine, or to put a file from your local machine onto the remote machine. (This is 
the exact opposite of telnet, which has everything relative to the remote machine. It is important to remember which command moves in which direction, or you could overwrite files accidentally.)

<BR>

<P>The quotation marks around the filenames in the preceding examples are optional for most versions of FTP, but they do prevent shell expansion of characters, so it's best to use them. For most files, the quotation marks are not needed, but using them is 
a good habit to get into.

<BR>

<P>Some FTP versions provide a wildcard capability using the commands mget and mput. Both the FTP get and put commands usually transfer only one file at a time, which must be completely specified (no wildcards). The mget and mput commands enable you to use 
wildcards. For example, to transfer all the files with a .doc extension, you could issue the command:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">mget *.doc</FONT></PRE>

<P>You will have to try the mget and mput commands to see if they work on your FTP version. (Some FTP get and put commands allow wildcards, too, so you can try wildcards in a command line to see if they work, instead.)

<BR>

<P>FTP allows file transfers in several formats, which are usually system dependent. The majority of systems (including Linux systems) have only two modes: ASCII and binary. Some mainframe installations add support for EBCDIC, while many sites have a local 
type that is designed for fast transfers between local network machines (the local type may use 32- or 64-bit words).

<BR>

<P>The difference between the binary and ASCII modes is simple. Text transfers use ASCII characters separated by carriage return and new-line characters. Binary mode allows transfer of characters with no conversion or formatting. Binary mode is faster than 
text and also allows for the transfer of all ASCII values (necessary for non-text files). FTP cannot transfer file permissions because these are not specified as part of the protocol.

<BR>

<P>Linux' FTP provides two modes of file transfer: ASCII and Binary. Some systems automatically switch between the two when they recognize a file is binary format, but you shouldn't count on the switching unless you've tested it before and know it works. 
To be sure, it is a good idea to manually set the mode. By default, most FTP versions start up in ASCII mode, although a few start in Binary.

<BR>

<P>To set FTP in binary transfer mode (for any executable file or file with special characters embedded for spreadsheets, word processors, graphics, and so on), type the command

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">binary</FONT></PRE>

<P>You can toggle back to ASCII mode with the command ascii. Since you will most likely be checking remote sites for new binaries or libraries of source code, it is a good idea to use binary mode for most transfers. If you transfer a binary file in ASCII 
mode, it will not be usable on your system.

<BR>

<P>ASCII mode includes only the valid ASCII characters and not the 8-bit values stored in binaries. Transferring an ASCII file in Binary mode does not affect the contents except in very rare instances.

<BR>

<P>To quit FTP, type the command quit or exit. Both will close your session on the remote machine, and then terminate FTP on your local machine. Users have a number of commands available within most versions of FTP. The following list outlines the ones 
most frequently used:

<BR>



<TABLE  BORDERCOLOR=#000040 BORDER=1 CELLSPACING=2 WIDTH="100%" CELLPADDING=2 >

<TR>

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

ascii

</FONT>

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

Switches to ASCII transfer mode</FONT>

<TR>

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

binary

</FONT>

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

Switches to binary transfer mode</FONT>

<TR>

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

cd

</FONT>

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

Changes directory on the server</FONT>

<TR>

⌨️ 快捷键说明

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