⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 term.html

📁 这是很好的学习嵌入式LINUX的文章
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta name="generator" content="HTML Tidy, see www.w3.org" /><title>Terminals</title><meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.7" /><link rel="HOME" title="FreeBSD Handbook" href="index.html" /><link rel="UP" title="Serial Communications" href="serialcomms.html" /><link rel="PREVIOUS" title="Introduction" href="serial.html" /><link rel="NEXT" title="Dial-in Service" href="dialup.html" /><link rel="STYLESHEET" type="text/css" href="docbook.css" /></head><body class="SECT1" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#840084"alink="#0000FF"><div class="NAVHEADER"><table summary="Header navigation table" width="100%" border="0" cellpadding="0"cellspacing="0"><tr><th colspan="3" align="center">FreeBSD Handbook</th></tr><tr><td width="10%" align="left" valign="bottom"><a href="serial.html"accesskey="P">Prev</a></td><td width="80%" align="center" valign="bottom">Chapter 20 Serial Communications</td><td width="10%" align="right" valign="bottom"><a href="dialup.html"accesskey="N">Next</a></td></tr></table><hr align="LEFT" width="100%" /></div><div class="SECT1"><h1 class="SECT1"><a id="TERM" name="TERM">20.3 Terminals</a></h1><i class="AUTHORGROUP"><span class="CONTRIB">Contributed by</span> Sean Kelly.</i> <p>Terminals provide a convenient and low-cost way to access your FreeBSD system when youare not at the computer's console or on a connected network. This section describes howto use terminals with FreeBSD.</p><div class="SECT2"><h2 class="SECT2"><a id="TERM-USES" name="TERM-USES">20.3.1 Uses and Types ofTerminals</a></h2><p>The original <span class="TRADEMARK">UNIX</span>&reg; systems did not have consoles.Instead, people logged in and ran programs through terminals that were connected to thecomputer's serial ports. It is quite similar to using a modem and terminal software todial into a remote system to do text-only work.</p><p>Today's PCs have consoles capable of high quality graphics, but the ability toestablish a login session on a serial port still exists in nearly every <spanclass="TRADEMARK">UNIX</span> style operating system today; FreeBSD is no exception. Byusing a terminal attached to an unused serial port, you can log in and run any textprogram that you would normally run on the console or in an <ttclass="COMMAND">xterm</tt> window in the X Window System.</p><p>For the business user, you can attach many terminals to a FreeBSD system and placethem on your employees' desktops. For a home user, a spare computer such as an older IBMPC or a <span class="TRADEMARK">Macintosh</span>&reg; can be a terminal wired into a morepowerful computer running FreeBSD. You can turn what might otherwise be a single-usercomputer into a powerful multiple user system.</p><p>For FreeBSD, there are three kinds of terminals:</p><ul><li><p><a href="term.html#TERM-DUMB">Dumb terminals</a></p></li><li><p><a href="term.html#TERM-PCS">PCs acting as terminals</a></p></li><li><p><a href="term.html#TERM-X">X terminals</a></p></li></ul><p>The remaining subsections describe each kind.</p><div class="SECT3"><h3 class="SECT3"><a id="TERM-DUMB" name="TERM-DUMB">20.3.1.1 Dumb Terminals</a></h3><p>Dumb terminals are specialized pieces of hardware that let you connect to computersover serial lines. They are called ``dumb'' because they have only enough computationalpower to display, send, and receive text. You cannot run any programs on them. It is thecomputer to which you connect them that has all the power to run text editors, compilers,email, games, and so forth.</p><p>There are hundreds of kinds of dumb terminals made by many manufacturers, includingDigital Equipment Corporation's VT-100 and Wyse's WY-75. Just about any kind will workwith FreeBSD. Some high-end terminals can even display graphics, but only certainsoftware packages can take advantage of these advanced features.</p><p>Dumb terminals are popular in work environments where workers do not need access tographical applications such as those provided by the X Window System.</p></div><div class="SECT3"><h3 class="SECT3"><a id="TERM-PCS" name="TERM-PCS">20.3.1.2 PCs Acting asTerminals</a></h3><p>If a <a href="term.html#TERM-DUMB">dumb terminal</a> has just enough ability todisplay, send, and receive text, then certainly any spare personal computer can be a dumbterminal. All you need is the proper cable and some <span class="emphasis"><iclass="EMPHASIS">terminal emulation</i></span> software to run on the computer.</p><p>Such a configuration is popular in homes. For example, if your spouse is busy workingon your FreeBSD system's console, you can do some text-only work at the same time from aless powerful personal computer hooked up as a terminal to the FreeBSD system.</p></div><div class="SECT3"><h3 class="SECT3"><a id="TERM-X" name="TERM-X">20.3.1.3 X Terminals</a></h3><p>X terminals are the most sophisticated kind of terminal available. Instead ofconnecting to a serial port, they usually connect to a network like Ethernet. Instead ofbeing relegated to text-only applications, they can display any X application.</p><p>We introduce X terminals just for the sake of completeness. However, this chapter does<span class="emphasis"><i class="EMPHASIS">not</i></span> cover setup, configuration, oruse of X terminals.</p></div></div><div class="SECT2"><h2 class="SECT2"><a id="TERM-CONFIG" name="TERM-CONFIG">20.3.2 Configuration</a></h2><p>This section describes what you need to configure on your FreeBSD system to enable alogin session on a terminal. It assumes you have already configured your kernel tosupport the serial port to which the terminal is connected--and that you have connectedit.</p><p>Recall from <a href="boot.html">Chapter 12</a> that the <tt class="COMMAND">init</tt>process is responsible for all process control and initialization at system startup. Oneof the tasks performed by <tt class="COMMAND">init</tt> is to read the <ttclass="FILENAME">/etc/ttys</tt> file and start a <tt class="COMMAND">getty</tt> processon the available terminals. The <tt class="COMMAND">getty</tt> process is responsible forreading a login name and starting the <tt class="COMMAND">login</tt> program.</p><p>Thus, to configure terminals for your FreeBSD system the following steps should betaken as <tt class="USERNAME">root</tt>:</p><div class="PROCEDURE"><ol type="1"><li><p>Add a line to <tt class="FILENAME">/etc/ttys</tt> for the entry in the <ttclass="FILENAME">/dev</tt> directory for the serial port if it is not already there.</p></li><li><p>Specify that <tt class="COMMAND">/usr/libexec/getty</tt> be run on the port, andspecify the appropriate <var class="REPLACEABLE">getty</var> type from the <ttclass="FILENAME">/etc/gettytab</tt> file.</p></li><li><p>Specify the default terminal type.</p></li><li><p>Set the port to ``on.''</p></li><li><p>Specify whether the port should be ``secure.''</p></li><li><p>Force <tt class="COMMAND">init</tt> to reread the <tt class="FILENAME">/etc/ttys</tt>file.</p></li></ol></div><p>As an optional step, you may wish to create a custom <varclass="REPLACEABLE">getty</var> type for use in step 2 by making an entry in <ttclass="FILENAME">/etc/gettytab</tt>. This chapter does not explain how to do so; you areencouraged to see the <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=gettytab&sektion=5"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">gettytab</span>(5)</span></a> and the <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=getty&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">getty</span>(8)</span></a> manual pagesfor more information.</p><div class="SECT3"><h3 class="SECT3"><a id="TERM-ETCTTYS" name="TERM-ETCTTYS">20.3.2.1 Adding an Entry to<tt class="FILENAME">/etc/ttys</tt></a></h3><p>The <tt class="FILENAME">/etc/ttys</tt> file lists all of the ports on your FreeBSDsystem where you want to allow logins. For example, the first virtual console <ttclass="FILENAME">ttyv0</tt> has an entry in this file. You can log in on the consoleusing this entry. This file also contains entries for the other virtual consoles, serialports, and pseudo-ttys. For a hardwired terminal, just list the serial port's <ttclass="FILENAME">/dev</tt> entry without the <tt class="FILENAME">/dev</tt> part (forexample, <tt class="FILENAME">/dev/ttyv0</tt> would be listed as <ttclass="DEVICENAME">ttyv0</tt>).</p><p>A default FreeBSD install includes an <tt class="FILENAME">/etc/ttys</tt> file withsupport for the first four serial ports: <tt class="FILENAME">ttyd0</tt> through <ttclass="FILENAME">ttyd3</tt>. If you are attaching a terminal to one of those ports, youdo not need to add another entry.</p><div class="EXAMPLE"><a id="EX-ETC-TTYS" name="EX-ETC-TTYS"></a><p><b>Example 20-1. Adding Terminal Entries to <ttclass="FILENAME">/etc/ttys</tt></b></p><p>Suppose we would like to connect two terminals to the system: a Wyse-50 and an old 286IBM PC running <b class="APPLICATION">Procomm</b> terminal software emulating a VT-100terminal. We connect the Wyse to the second serial port and the 286 to the sixth serialport (a port on a multiport serial card). The corresponding entries in the <ttclass="FILENAME">/etc/ttys</tt> file would look like this:</p><pre class="PROGRAMLISTING">ttyd1<a id="CO-TTYS-LINE1COL1" name="CO-TTYS-LINE1COL1"><imgsrc="./imagelib/callouts/1.png" hspace="0" vspace="0" border="0"alt="(1)" /></a>  "/usr/libexec/getty std.38400"<a id="CO-TTYS-LINE1COL2"name="CO-TTYS-LINE1COL2"><img src="./imagelib/callouts/2.png" hspace="0" vspace="0"border="0" alt="(2)" /></a>  wy50<a id="CO-TTYS-LINE1COL3" name="CO-TTYS-LINE1COL3"><imgsrc="./imagelib/callouts/3.png" hspace="0" vspace="0" border="0" alt="(3)" /></a>  on<aid="CO-TTYS-LINE1COL4" name="CO-TTYS-LINE1COL4"><img src="./imagelib/callouts/4.png"hspace="0" vspace="0" border="0" alt="(4)" /></a>  insecure<a id="CO-TTYS-LINE1COL5"name="CO-TTYS-LINE1COL5"><img src="./imagelib/callouts/5.png" hspace="0" vspace="0"border="0" alt="(5)" /></a>ttyd5   "/usr/libexec/getty std.19200"  vt100  on  insecure     </pre>

⌨️ 快捷键说明

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