📄 unx08.htm
字号:
<CENTER><A ID="I21" NAME="I21">
<FONT SIZE=3><B>Using Telnet</B>
<BR></FONT></A></CENTER></H4>
<P>The telnet service is used to communicate with a remote host via the telnet protocol. Invoking telnet with the remote host as an argument causes telnet to connect to that host. The remote telnet server usually initiates a login just as you would get on
a terminal connected to the machine. After your login name and password are entered and verified, you will see the shell prompt on the remote machine. All commands and input you enter go to the remote; all output you receive comes from the remote.
<BR></P>
<P>If you wish to enter telnet command mode while you are connected to a remote, type the escape character. The default escape character is Ctrl+], but this can be changed via the set command. To return to the remote connection, simply execute a command. A
set command will do this. If you have nothing you want to send or set, do a send nop. The nop argument stands for no operation.
<BR></P>
<P>If you enter telnet without any arguments, you will start up the telnet service in command mode. You will see a special telnet prompt (telnet>). You can enter any of the telnet commands. Following is a list of some of the most common commands you
might use. Refer to your system's manual for telnet, for a complete list.
<BR></P>
<TABLE BORDER>
<TR>
<TD>
<P>open</P>
<TD>
<P>Connects to specified host.</P>
<TR>
<TD>
<P>close</P>
<TD>
<P>Disconnects from host and returns to command mode.</P>
<TR>
<TD>
<P>quit</P>
<TD>
<P>Closes the connection (if one exists) and exits telnet.</P>
<TR>
<TD>
<P>set</P>
<TD>
<P>Changes the value for a given argument.</P>
<TR>
<TD>
<P>send</P>
<TD>
<P>Sends a command to the remote and returns to remote connection.</P>
<TR>
<TD>
<P>display</P>
<TD>
<P>Shows current setting of telnet configuration.</P>
<TR>
<TD>
<P>status</P>
<TD>
<P>Shows current status of telnet connection.</P>
<TR>
<TD>
<P>?</P>
<TD>
<P>Gives help.</P></TABLE>
<P>The following sections look at some of these in a bit more detail.
<BR></P>
<H5 ALIGN="CENTER">
<CENTER><A ID="I22" NAME="I22">
<FONT SIZE=3><B>open</B>
<BR></FONT></A></CENTER></H5>
<P>The open command takes two parameters, host and port. The host, which is mandatory, can be a hostname or an IP address. This specifies the remote host to which a connection is to be established. This remote host must be reachable via the network and
must support the telnet service. The port, which is optional, specifies the port number to use in connecting to the remote host. By default, the port to which telnet connects is the well-known telnet port (23). When a connection on the remote comes in on
the telnet port, the remote's telnet service handles the connection. The remote telnet service assumes that the local connector wants to log in and invokes the login process on this connection. You can use this feature to do certain kinds of debugging and
troubleshooting. For example, to connect to the mail server on a machine, you could enter telnet <I>hostname</I> smtp (or replace smtp with 25 if the first doesn't work). This will connect you directly to the Simple Mail Transfer Protocol on
<I>hostname</I> and you can use this connection to troubleshoot mail problems. Sometimes network services are offered by telnet to a specific port number. For example, many gopher and WWW providers offer a special port for telnet access to the service.
<BR></P>
<P>In this default mode, a telnet open is somewhat like an rlogin. A remote login is initiated on the remote host. But the telnet protocol, unlike rlogin, does not perform any conveniences for you. It does not propagate any of your local environment. It
does not perform any part of the login procedure (user identification and authentication).
<BR></P>
<P>If the first thing you will use telnet for is an open command, you do not need to enter telnet command mode at all. On the telnet command line, you can enter a host followed optionally by a port number. This causes telnet to immediately do an open with
the command-line arguments.
<BR></P>
<H5 ALIGN="CENTER">
<CENTER><A ID="I23" NAME="I23">
<FONT SIZE=3><B>close</B>
<BR></FONT></A></CENTER></H5>
<P>The close command terminates the open connection (if one exists). On some versions of telnet, this does not exit telnet command mode. So if you are connected to Host B but decide you really want to be connected to Host C, enter close and then enter an
open B command.
<BR></P>
<H5 ALIGN="CENTER">
<CENTER><A ID="I24" NAME="I24">
<FONT SIZE=3><B>quit</B>
<BR></FONT></A></CENTER></H5>
<P>The quit command should be used when you are finished using telnet. This will perform a close on the open connection (if one exists). Then it terminates the telnet service, returning you to your local shell prompt.
<BR></P>
<H5 ALIGN="CENTER">
<CENTER><A ID="I25" NAME="I25">
<FONT SIZE=3><B>set</B>
<BR></FONT></A></CENTER></H5>
<P>Telnet has several internal variables used for configuration. You can use the set command to change these values. To see the current variable values, use the display command. The telnet escape character can be changed via set.
<BR></P>
<HR ALIGN=CENTER>
<NOTE>
<IMG SRC="imp.gif" WIDTH = 68 HEIGHT = 35><B>TIP: </B>You can set certain special characters (such as erase) with telnet, but these settings may only work if you run telnet in line mode. Line mode is often used for connecting to remote machines that have
line-oriented user interfaces and allows you to compose an entire line of text input before sending it to the remote (when you press return). You should probably not use line mode when connecting to a UNIX machine since interactive commands (such as vi),
job control, and some shell history (ksh interactive command editing) rely on receiving characters as they are typed.
<BR></NOTE>
<HR ALIGN=CENTER>
<H5 ALIGN="CENTER">
<CENTER><A ID="I26" NAME="I26">
<FONT SIZE=3><B>?</B>
<BR></FONT></A></CENTER></H5>
<P>The question mark (?) is a telnet command that, without arguments, gives a list of all the telnet commands. This is useful if you've forgotten the name of a command. To get help about a specific command, use ? with the command as an argument. The ? can
also be used as an argument to the set, send, and toggle commands to list the valid arguments of the command.
<BR></P>
<H4 ALIGN="CENTER">
<CENTER><A ID="I27" NAME="I27">
<FONT SIZE=3><B>Before Using </B><B>cu</B>
<BR></FONT></A></CENTER></H4>
<P>Before you can use cu, your system administrator will need to configure the appropriate devices and machines for UUCP access. Check your system's UUCP documentation for information on how to do this.
<BR></P>
<H4 ALIGN="CENTER">
<CENTER><A ID="I28" NAME="I28">
<FONT SIZE=3><B>Using </B><B>cu</B>
<BR></FONT></A></CENTER></H4>
<P>The cu service calls up another system. This service is used only to connect two computers via phone lines. Your local host must have an outgoing modem and the remote host must have a modem that supports incoming calls.
<BR></P>
<P>Your system administrator may have configured the parameters necessary to call up certain systems. This configuration is kept in the file /etc/uucp/Systems.
<BR></P>
<HR ALIGN=CENTER>
<NOTE>
<IMG SRC="note.gif" WIDTH = 35 HEIGHT = 35><B>NOTE:</B> The actual file depends on which version of UUCP you have. This is correct for SVR4. Since the location may vary, consider this the "systems" file.
<BR></NOTE>
<HR ALIGN=CENTER>
<P>You can enter cu <I>system-name</I> to dial the remote host. If the remote host has not been configured in the /etc/uucp/Systems file, you can specify the necessary parameters on the command line. The cu <I>phone-number</I> command will call up the
specified phone number. For example, cu 9=14085551212 will call using the ad device and give it the phone number 914085551212. The equals sign specifies that a pause is desired before the next digit is dialed.
<BR></P>
<P>You can also call up using a local device by specifying it with the -l option. You can use the -l option to specify the device to use for making the connection. This is generally used only for hardwired connections: cu -l <I>dev</I> dir will connect
directly to the line named dev.
<BR></P>
<H3 ALIGN="CENTER">
<CENTER><A ID="I29" NAME="I29">
<FONT SIZE=4><B>Transferring Files—</B><B>rcp</B><B>, </B><B>ftp</B><B>, </B><B>uucp</B>
<BR></FONT></A></CENTER></H3>
<P>Files are the basis for everything you do in UNIX. When you execute a command (aside from Shell built-ins), the associated file contains the executing instructions. When you store or retrieve information, the data is kept in one or more files. The UNIX
interface to hardware devices is through device files. Files are pervasive. Therefore, having the necessary files within your reach is extremely important.
<BR></P>
<P>Sometimes files you need are not stored on your local machine. Client-server environments are designed to provide a means of sharing files among many machines. When machines on a LAN are configured to share files (via the network), many more files
become reachable to you. If you are using NFS, some directories on your system will be mounted from remote machines. These directories and files will be available as part of the normal UNIX file system, and you need no special techniques to access them.
<BR></P>
<P>Not all UNIX environments are configured this way. Even those that are may not share all file systems of all machines. Many files exist outside of a local LAN environment. In these cases, you may want to obtain a copy of a file from somewhere other than
your local environment. You could use the tools in I'm on the wire to remotely log in and access them. But if you need to execute the file locally, or wish to have your own copy of the file, you need to copy the remote file to your local system.
<BR></P>
<P>The next section presents several tools to do remote copies. Your local configuration, the remote configuration, the way the remote and local configurations are connected, as well as your personal preference will determine which tool you choose.
<BR></P>
<H4 ALIGN="CENTER">
<CENTER><A ID="I30" NAME="I30">
<FONT SIZE=3><B>Using </B><B>rcp</B>
<BR></FONT></A></CENTER></H4>
<P>Before you read this subsection, you should review the section "Before Using rlogin, rsh, and rcp." For rcp to work, you must configure the remote machine(s) so that user authentication is not necessary. For each remote you access via rcp, an
entry in one or both of /etc/hosts.equiv and $HOME/.rhosts is mandatory. This is because rcp does not have a mechanism for in-process authentication (unlike rlogin).
<BR></P>
<P>Once the configuration is complete, you can use rcp in much the same way you use the cp command. Each command basically says to "copy File A to Location B." The rcp command adds some syntax that enables you to specify remote machines and
users.
<BR></P>
<H5 ALIGN="CENTER">
<CENTER><A ID="I31" NAME="I31">
<FONT SIZE=3><B>Specifying a Remote File</B>
<BR></FONT></A></CENTER></H5>
<P>You can specify a remote file in several different ways. In general, unless a hostname is specified, the file is considered local. If the character string has a colon (:) before any slashes (/), the string before the colon specifies the remote host and
the string after the colon specifies the file path. Here are three forms of the complete remote file specification:
<BR></P>
<PRE>
<BR>hostname:filepath
<BR>user@hostname:filepath
<BR>user@hostname.domain:filepath</PRE>
<P>The file path in each can be an absolute path, a relative path, or blank. If it is relative, is it relative to the remote user's HOME directory. The remote user is considered the same as the local user unless explicitly included in the remote
specification. In the second and third forms above, the remote user is explicitly included.
<BR></P>
<P>If the file path is absolute, this is an absolute path on the remote system. If the file path is blank, the user's HOME directory is assumed.
<BR></P>
<P>The hostname can be a simple name or an alias of the remote machine, or it can be a host domain name as in the third form above.
<BR></P>
<P>If you wish to use a different user account on the remote machine, you can specify the remote file, including the user name. The user name must refer to an account on the remote machine, and the user's $HOME/.rhosts file must contain the proper entry
for your local machine.
<BR></P>
<H5 ALIGN="CENTER">
<CENTER><A ID="I32" NAME="I32">
<FONT SIZE=3><B>Understanding the </B><B>rcp</B><B> Command Line Syntax</B>
<BR></FONT></A></CENTER></H5>
<P>The rcp command line is flexible; to support this flexibility, there are a few variations of the command line:
<BR></P>
<UL>
<LI><B>rcp single-file dest</B><B>.</B> In this variation, the first argument, single-file, is a single file. This file is copied to the destination dest. If dest is an existing directory, the file dest/single-file is created. If dest is an existing file,
dest is overwritten with single-file. Otherwise the file dest is created by copying single-file.
<BR>
<BR></LI>
<LI><B>rcp sources dest</B><B>.</B> In this variation, the first argument, sources, is one or more files and/or directories. dest must be a directory. Only the members of sources that are files are copied to the destination dest. If dest is an existing
directory, the files are copied under directory dest. It is unwise to specify a dest directory that does not exist with this form of the rcp command. The results vary from system to system. See the next form for copying a single directory.
<BR>
<BR></LI>
<LI><B>rcp -r sources dest</B><B>.</B> By adding the option -r, the files in source as well as the directories (and all their subdirectories) are copied to dest.
<BR>
<BR>If sources is a single directory, it is okay to specify a destination dest that doesn't exist. The directory will be created for you. This is probably what you want. Beware of this situation, because if dest does exist, the copied directory will be
placed as a subdirectory of dest.
<BR>
<BR>If sources is multiple directories and/or files, dest must be an existing directory. If it doesn't exist, the results are not specified and differ from one UNIX system to another.
<BR>
<BR>Each version of the rcp command line supports an additional option, -p. This option causes rcp to preserve the modification times as well as the modes when the copy is made.
<BR>
<BR></LI></UL>
<H4 ALIGN="CENTER">
<CENTER><A ID="I33" NAME="I33">
<FONT SIZE=3><B>Using ftp</B>
<BR></FONT></A></CENTER></H4>
<P>The ftp service is the interface to the file transfer protocol. This service provides a connection service to a remote computer along with file manipulation functions including sending and receiving files. It also provides user authentication, unlike
rcp. It supports different file types.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -