📄 583-585.html
字号:
<HTML>
<HEAD>
<TITLE>Special Edition Using Linux, Fourth Edition:Accessing the Network with telnet, ftp, and the r-Commands</TITLE>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<!--ISBN=0789717468//-->
<!--TITLE=Special Edition Using Linux, Fourth Edition//-->
<!--AUTHOR=Jack Tackett//-->
<!--AUTHOR=Jr.//-->
<!--AUTHOR=Steve Burnett//-->
<!--PUBLISHER=Macmillan Computer Publishing//-->
<!--IMPRINT=Que//-->
<!--CHAPTER=30//-->
<!--PAGES=583-585//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="581-583.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="585-588.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<P>As you can see, <TT>ftp</TT> has quite a few commands. However, you really need to look at only the ones that you use most frequently.</P>
<P><FONT SIZE="+1"><B>Starting an FTP Session</B></FONT></P>
<P>The <TT>open</TT> command is used to open an FTP session with a remote host. Its syntax is as follows:</P>
<!-- CODE SNIP //-->
<PRE>
open <I>hostname</I>
</PRE>
<!-- END CODE SNIP //-->
<P>You usually need this command only if you’re going to connect to more than one site during an FTP session. If you want to connect to only one computer during the session, just specify the remote host name on the command line as an argument to the <TT>ftp</TT> command.</P>
<P><FONT SIZE="+1"><B>Ending an FTP Session</B></FONT></P>
<P>The <TT>close</TT>, <TT>disconnect</TT>, <TT>quit</TT>, and <TT>bye</TT> commands are used to end an FTP session with a remote computer. The identical <TT>close</TT> and <TT>disconnect</TT> commands close your connection to the remote computer but leave you in the <TT>ftp</TT> program on your local computer. The <TT>quit</TT>, <TT>exit</TT>, and <TT>bye</TT> commands close your connection to the remote computer if one is active; then they exit the <TT>ftp</TT> program on your computer.</P>
<P><FONT SIZE="+1"><B>Changing Directories</B></FONT></P>
<P>The <TT>cd <I>[directory]</I></TT> command is used to change directories on the remote computer during your FTP session. The <TT>cdup</TT> command takes you to the parent directory of the current directory. The <TT>lcd</TT> command changes your local directory so that you can specify where to find or put local files.</P>
<P><FONT SIZE="+1"><B>Remote Directory Listing</B></FONT></P>
<P>The <TT>ls</TT> command lists the contents of a remote directory, just like <TT>ls</TT> from an interactive shell. The syntax for <TT>ls</TT> is this:</P>
<!-- CODE SNIP //-->
<PRE>
ls <I>[directory] [local_file]</I>
</PRE>
<!-- END CODE SNIP //-->
<P>If a directory is specified as an argument, <TT>ls</TT> lists the contents of that directory. If a local filename is given, the directory listing is put into the file you specified on your local computer.</P>
<P>The <TT>dir</TT> and <TT>ls</TT> commands provide a long listing, giving protections, size, owner, and date. The syntax of the <TT>dir</TT> command is as follows:</P>
<!-- CODE SNIP //-->
<PRE>
dir <I>[directory] [local_file]</I>
</PRE>
<!-- END CODE SNIP //-->
<P>The following is an example of a <TT>dir</TT> directory listing:</P>
<!-- CODE SNIP //-->
<PRE>
-rw-r--r-- 1 root archive 2928 May 17 1993 README
-rw-r--r-- 1 root archive 1723 Jun 29 1993 README.NFS
dr-xr-xr-x 2 root wheel 8192 Jun 6 12:16 bind
-rwxr-xr-x 5 root wheel 8192 Aug 2 06:11 decus
drwxr-xr-x 19 root archive 8192 Feb 7 1994 doc
drwxr-xr-x 6 root wheel 8192 Jun 15 15:45 edu
dr-xr-xr-x 7 root wheel 8192 Sep 28 09:33 etc
</PRE>
<!-- END CODE SNIP //-->
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR>• <B>See</B> “Managing File Systems” <B>p. 265</B> for an explanation of the above result<HR></FONT>
</BLOCKQUOTE>
<P><FONT SIZE="+1"><B>Getting Files from a Remote System</B></FONT></P>
<P>The <TT>get</TT> and <TT>mget</TT> commands are used to retrieve files from a remote computer. The <TT>get</TT> command retrieves the file that you specify as an argument (<I>filename</I>). The following is the <TT>get</TT> command’s syntax:</P>
<!-- CODE SNIP //-->
<PRE>
get <I>filename [remote_filename]</I>
</PRE>
<!-- END CODE SNIP //-->
<P>You can also give a local filename, which is the name of the file when it’s created on your local computer. If you don’t give a local filename, <I>remote_filename</I> is used.</P>
<P>The <TT>mget</TT> command retrieves multiple files at once. <TT>mget</TT> ’s syntax is as follows:</P>
<!-- CODE SNIP //-->
<PRE>
mget <I>filename_list</I>
</PRE>
<!-- END CODE SNIP //-->
<P>You specify these files by giving a list of filenames separated by spaces or by using a wildcard pattern to <TT>mget</TT>. You’re prompted for each file. To turn prompting off, use the <TT>prompt</TT> command before using <TT>mget</TT>. In both cases, the files are transferred as ASCII files, unless you’ve set the transfer mode to something else.</P>
<P><FONT SIZE="+1"><B>Sending Files to a Remote System</B></FONT></P>
<P>The <TT>put</TT> and <TT>mput</TT> commands are used to send files to a remote computer. The <TT>put</TT> command sends the local file that you specify as an argument. The syntax is this:</P>
<!-- CODE SNIP //-->
<PRE>
put <I>filename</I>
</PRE>
<!-- END CODE SNIP //-->
<P>The <TT>mput</TT> command sends a series of local files. The syntax for <TT>mput</TT> is shown here:</P>
<!-- CODE SNIP //-->
<PRE>
mput <I>filename_list</I>
</PRE>
<!-- END CODE SNIP //-->
<P>You specify these files by giving a list of filenames separated by spaces or by using a wildcard pattern to <TT>mput</TT>. When using <TT>mput</TT>, you’re prompted for each file. To turn prompting off, use the <TT>prompt</TT> command. In both cases, the files are transferred as ASCII files, unless you’ve set the transfer mode to something else.</P>
<P><FONT SIZE="+1"><B>Changing the File Transfer Mode</B></FONT></P>
<P><TT>ftp</TT> transfers files as ASCII files unless you specify something else. This is fine for plain text but renders any binary data useless. The <TT>ascii</TT> and <TT>binary</TT> commands set the transfer mode so that you can prevent damage to your binary files.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE: </B>Many files that you’ll want to transfer are in binary format. Files ending with .tar are archives created with the <TT>tar</TT> command. Files ending in .Z and .gz are compressed with either the <TT>compress</TT> command or the GNU <TT>gzip</TT> command, respectively. Files ending in .zip are compressed archives created with <TT>PKZIP</TT>. When in doubt, use binary transfer mode. Using ASCII mode corrupts binary data files.<HR></FONT>
</BLOCKQUOTE>
<P><FONT SIZE="+1"><B>Checking Transfer Status</B></FONT></P>
<P>When transferring a large file, you may find it useful to have <TT>ftp</TT> give you feedback on how far along the transfer is. The <TT>hash</TT> command causes <TT>ftp</TT> to print a # character on-screen each time the transmission of a data buffer has been completed. This command works for sending and receiving files.</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="581-583.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="585-588.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 + -