📄 unx08.htm
字号:
<BR></P>
<P>To connect with a remote host, you can simply type ftp <I>hostname</I>. The <I>hostname</I> can either be a hostname or an Internet address. If you do not specify a remote host on the command line, you enter ftp command mode. Then you can use the open
command to initiate a connection.
<BR></P>
<P>By default, when a connection is initiated via ftp, the remote ftp server starts up the login process. You must enter a valid user name and password in order to access the remote system. Once you have been authenticated, you are connected to the remote
ftp server and it awaits your commands.
<BR></P>
<P>The ftp service has a large number of commands. Several common commands are covered in Table 8.2. For complete details, refer to your system's manual for ftp.
<BR></P>
<UL>
<LH><B>Table 8.2. Common ftp service commands.</B>
<BR></LH></UL>
<TABLE BORDER>
<TR>
<TD COLSPAN=2>
<P><B>Connection-Related Commands</B></P>
<TR>
<TD>
<P>open</P>
<TD>
<P>Open a connection to specified host.</P>
<TR>
<TD>
<P>close</P>
<TD>
<P>Close current open connection. </P>
<TR>
<TD>
<P>quit</P>
<TD>
<P>Close current open connection and exit ftp.</P>
<TR>
<TD COLSPAN=2>
<P><B>File Transfer—Related Commands</B></P>
<TR>
<TD>
<P>binary</P>
<TD>
<P>Change the file representation type to binary.</P>
<TR>
<TD>
<P>ascii</P>
<TD>
<P>Change the file representation type to ascii.</P>
<TR>
<TD>
<P>put</P>
<TD>
<P>Transfer a single file from the local to the remote host.</P>
<TR>
<TD>
<P>mput</P>
<TD>
<P>Transfer multiple files from the local to the remote host.</P>
<TR>
<TD>
<P>get</P>
<TD>
<P>Transfer a single file from the remote to the local host.</P>
<TR>
<TD>
<P>mget</P>
<TD>
<P>Transfer multiple files from the remote to the local host.</P>
<TR>
<TD COLSPAN=2>
<P><B>File- and Directory-Management Commands</B></P>
<TR>
<TD>
<P>cd</P>
<TD>
<P>Change remote's current working directory (UNIX cd).</P>
<TR>
<TD>
<P>lcd</P>
<TD>
<P>Change the local's current working directory (UNIX cd).</P>
<TR>
<TD>
<P>cdup</P>
<TD>
<P>Change remote's current working directory to be the parent directory (UNIX cd ..).</P>
<TR>
<TD>
<P>dir</P>
<TD>
<P>List the remote's current working directory (UNIX ls).</P>
<TR>
<TD>
<P>pwd</P>
<TD>
<P>Print the remote's current working directory (UNIX pwd).</P>
<TR>
<TD>
<P>mkdir</P>
<TD>
<P>Make a new directory on the remote (UNIX mkdir).</P>
<TR>
<TD>
<P>rmdir</P>
<TD>
<P>Delete a directory on the remote (UNIX rmdir).</P>
<TR>
<TD>
<P>rename</P>
<TD>
<P>Change the name of a remote file or directory (UNIX mv).</P>
<TR>
<TD>
<P>delete</P>
<TD>
<P>Delete a remote file (UNIX rm, with one file specified).</P>
<TR>
<TD>
<P>mdelete</P>
<TD>
<P>Delete multiple remote files (UNIX rm, with multiple files).</P>
<TR>
<TD COLSPAN=2>
<P><B>Miscellaneous Commands</B></P>
<TR>
<TD>
<P>?</P>
<TD>
<P>Obtain help about ftp.</P>
<TR>
<TD>
<P>!</P>
<TD>
<P>Escape shell.</P></TABLE>
<H5 ALIGN="CENTER">
<CENTER><A ID="I34" NAME="I34">
<FONT SIZE=3><B>Connection-Related Commands</B>
<BR></FONT></A></CENTER></H5>
<P>The ftp connection-related commands are fairly straightforward. The open command tries to connect to the ftp server on the specified remote host. The close command terminates the open connection (if one exists) and then returns to command mode. This is
usually used when you want to connect to a different host, so you will commonly follow it with an open. The quit command closes the connection and then exits ftp.
<BR></P>
<H5 ALIGN="CENTER">
<CENTER><A ID="I35" NAME="I35">
<FONT SIZE=3><B>File Transfer—Related Commands</B>
<BR></FONT></A></CENTER></H5>
<P>The ftp service defines several file representation types for transfer. The two most common are ascii and binary. By default, the type is set to ascii. Any file that is plain ASCII text can be transferred using ascii type. Binary files, like a compiled
and linked executable file, must be transferred using binary type. Be sure to set the correct type before transferring any files.
<BR></P>
<HR ALIGN=CENTER>
<NOTE>
<IMG SRC="imp.gif" WIDTH = 68 HEIGHT = 35><B>TIP: </B>Transferring ASCII text files between UNIX machines is slightly faster with binary type, but using binary type to transfer an ASCII text file between a UNIX and a non-UNIX machine may corrupt the file.
<BR></NOTE>
<HR ALIGN=CENTER>
<HR ALIGN=CENTER>
<NOTE>
<IMG SRC="imp.gif" WIDTH = 68 HEIGHT = 35><B>TIP: </B>If you are having trouble decoding or executing a binary file you get elsewhere, check to make sure you used binary type transfer.
<BR></NOTE>
<HR ALIGN=CENTER>
<P>The get and mget commands transfer files from the remote to the local host. The put and mput commands transfer files from the local to the remote host. Both get and put transfer one file per command. On both of these commands you may specify the
destination for the file copy. If the destination is not specified, the file is placed in the current working directory. Both mget and mput transfer multiple files per command. The files are placed in the current working directory.
<BR></P>
<H5 ALIGN="CENTER">
<CENTER><A ID="I36" NAME="I36">
<FONT SIZE=3><B>File- and Directory-Management Commands</B>
<BR></FONT></A></CENTER></H5>
<P>The file- and directory-management commands are analogous to UNIX file and directory commands. In Table 8.2, the UNIX command that is analogous to the ftp command is given in parentheses. Remember that all of these commands, except lcd, operate on the
remote file system. If you need to perform more in-depth local file management, use the shell escape command (!) to escape to a local shell prompt.
<BR></P>
<H5 ALIGN="CENTER">
<CENTER><A ID="I37" NAME="I37">
<FONT SIZE=3><B>Miscellaneous Commands</B>
<BR></FONT></A></CENTER></H5>
<P>The ? command provides help about ftp commands. If you want help about a specific command, you can specify this command as the first argument to the ?. The shell escape command (!) is used to start a subshell on the local machine. This is very useful if
you need to perform some operations on your local host while you are connected to a remote ftp server. After you are finished working on the local host, simply exit the (sub)shell and you will return to ftp.
<BR></P>
<H5 ALIGN="CENTER">
<CENTER><A ID="I38" NAME="I38">
<FONT SIZE=3><B>Configuring with </B><B>.netrc</B>
<BR></FONT></A></CENTER></H5>
<P>The ftp command can automatically perform the login to remote ftp servers and initialize your connection. It does this by reading in the .netrc file in your home directory. You can configure the login, password, and account (some ftp servers allow or
require an extra account specification at authentication time) to use for a particular machine. In the following example from the .netrc file, automatic login is included as anonymous for several popular servers:
<BR></P>
<PRE>machine dg-rtp.rtp.dg.com login anonymous password sartin@pencom.com
machine town.hall.org login anonymous password sartin@pencom.com
machine ftp.uu.net login anonymous password sartin@pencom.com
machine rtfm.mit.edu login anonymous password sartin@pencom.com
machine ftp.x.org login anonymous password sartin@pencom.com
machine prep.ai.mit.edu login anonymous password sartin@pencom.com
machine ftp.ncsa.uiuc.edu login anonymous password sartin@pencom.com
machine emx.cc.utexas.edu login anonymous password sartin@pencom.com
machine boombox.micro.umn.edu login anonymous password sartin@pencom.com
machine rs.internic.net login anonymous password guest</PRE>
<HR ALIGN=CENTER>
<NOTE>
<IMG SRC="imp.gif" WIDTH = 68 HEIGHT = 35><B>TIP: </B>Most versions of ftp will use your .netrc for password information only if the file is readable by you only. For password security this file should be unreadable by others or, better yet, should contain
no sensitive passwords.
<BR></NOTE>
<HR ALIGN=CENTER>
<H5 ALIGN="CENTER">
<CENTER><A ID="I39" NAME="I39">
<FONT SIZE=3><B>Anonymous ftp</B>
<BR></FONT></A></CENTER></H5>
<P>There is a special login for ftp
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -