📄 consoles.html
字号:
<!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>Virtual Consoles and 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="UNIX Basics" href="basics.html" /><link rel="PREVIOUS" title="UNIX Basics" href="basics.html" /><link rel="NEXT" title="Permissions" href="permissions.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="basics.html"accesskey="P">Prev</a></td><td width="80%" align="center" valign="bottom">Chapter 3 UNIX Basics</td><td width="10%" align="right" valign="bottom"><a href="permissions.html"accesskey="N">Next</a></td></tr></table><hr align="LEFT" width="100%" /></div><div class="SECT1"><h1 class="SECT1"><a id="CONSOLES" name="CONSOLES">3.2 Virtual Consoles andTerminals</a></h1><p>FreeBSD can be used in various ways. One of them is typing commands to a textterminal. A lot of the flexibility and power of a <spanclass="TRADEMARK">UNIX</span>® operating system is readily available at your handswhen using FreeBSD this way. This section describes what ``terminals'' and ``consoles''are, and how you can use them in FreeBSD.</p><div class="SECT2"><h2 class="SECT2"><a id="CONSOLES-INTRO" name="CONSOLES-INTRO">3.2.1 The Console</a></h2><p>If you have not configured FreeBSD to automatically start a graphical environmentduring startup, the system will present you with a login prompt after it boots, rightafter the startup scripts finish running. You will see something similar to:</p><pre class="SCREEN">Additional ABI support:.Local package initialization:.Additional TCP options:.Fri Sep 20 13:01:06 EEST 2002FreeBSD/i386 (pc3.example.org) (ttyv0)login:</pre><p>The messages might be a bit different on your system, but you will see somethingsimilar. The last two lines are what we are interested in right now. The second last linereads:</p><pre class="PROGRAMLISTING">FreeBSD/i386 (pc3.example.org) (ttyv0)</pre><p>This line contains some bits of information about the system you have just booted. Youare looking at a ``FreeBSD'' console, running on an Intel or compatible processor of thex86 architecture<a id="AEN3628" name="AEN3628" href="#FTN.AEN3628"><spanclass="footnote">[1]</span></a>. The name of this machine (every <spanclass="TRADEMARK">UNIX</span> machine has a name) is <ttclass="HOSTID">pc3.example.org</tt>, and you are now looking at its system console--the<tt class="DEVICENAME">ttyv0</tt> terminal.</p><p>Finally, the last line is always:</p><pre class="PROGRAMLISTING">login:</pre><p>This is the part where you are supposed to type in your ``username'' to log intoFreeBSD. The next section describes how you can do this.</p></div><div class="SECT2"><h2 class="SECT2"><a id="CONSOLES-LOGIN" name="CONSOLES-LOGIN">3.2.2 Logging intoFreeBSD</a></h2><p>FreeBSD is a multiuser, multiprocessing system. This is the formal description that isusually given to a system that can be used by many different people, who simultaneouslyrun a lot of programs on a single machine.</p><p>Every multiuser system needs some way to distinguish one ``user'' from the rest. InFreeBSD (and all the <span class="TRADEMARK">UNIX</span> like operating systems), this isaccomplished by requiring that every user must ``log into'' the system before being ableto run programs. Every user has a unique name (the ``username'') and a personal, secretkey (the ``password''). FreeBSD will ask for these two before allowing a user to run anyprograms.</p><p>Right after FreeBSD boots and finishes running its startup scripts<a id="AEN3652"name="AEN3652" href="#FTN.AEN3652"><span class="footnote">[2]</span></a>, it will presentyou with a prompt and ask for a valid username:</p><pre class="SCREEN">login:</pre><p>For the sake of this example, let us assume that your username is <ttclass="USERNAME">john</tt>. Type <var class="LITERAL">john</var> at this prompt and press<b class="KEYCAP">Enter</b>. You should then be presented with a prompt to enter a``password'':</p><pre class="SCREEN">login: <kbd class="USERINPUT">john</kbd>Password:</pre><p>Type in <tt class="USERNAME">john</tt>'s password now, and press <bclass="KEYCAP">Enter</b>. The password is <span class="emphasis"><i class="EMPHASIS">notechoed!</i></span> You need not worry about this right now. Suffice it to say that it isdone for security reasons.</p><p>If you have typed your password correctly, you should by now be logged into FreeBSDand ready to try out all the available commands.</p><p>You should see the <acronym class="ACRONYM">MOTD</acronym> or message of the dayfollowed by a command prompt (a <var class="LITERAL">#</var>, <varclass="LITERAL">$</var>, or <var class="LITERAL">%</var> character). This indicates youhave successfully logged into FreeBSD.</p></div><div class="SECT2"><h2 class="SECT2"><a id="CONSOLES-VIRTUAL" name="CONSOLES-VIRTUAL">3.2.3 MultipleConsoles</a></h2><p>Running <span class="TRADEMARK">UNIX</span> commands in one console is fine, butFreeBSD can run many programs at once. Having one console where commands can be typedwould be a bit of a waste when an operating system like FreeBSD can run dozens ofprograms at the same time. This is where ``virtual consoles'' can be very helpful.</p><p>FreeBSD can be configured to present you with many different virtual consoles. You canswitch from one of them to any other virtual console by pressing a couple of keys on yourkeyboard. Each console has its own different output channel, and FreeBSD takes care ofproperly redirecting keyboard input and monitor output as you switch from one virtualconsole to the next.</p><p>Special key combinations have been reserved by FreeBSD for switching consoles<aid="AEN3679" name="AEN3679" href="#FTN.AEN3679"><span class="footnote">[3]</span></a>.You can use <b class="KEYCAP">Alt</b>-<b class="KEYCAP">F1</b>, <bclass="KEYCAP">Alt</b>-<b class="KEYCAP">F2</b>, through <b class="KEYCAP">Alt</b>-<bclass="KEYCAP">F8</b> to switch to a different virtual console in FreeBSD.</p><p>As you are switching from one console to the next, FreeBSD takes care of saving andrestoring the screen output. The result is an ``illusion'' of having multiple ``virtual''screens and keyboards that you can use to type commands for FreeBSD to run. The programsthat you launch on one virtual console do not stop running when that console is notvisible. They continue running when you have switched to a different virtual console.</p></div><div class="SECT2"><h2 class="SECT2"><a id="CONSOLES-TTYS" name="CONSOLES-TTYS">3.2.4 The <ttclass="FILENAME">/etc/ttys</tt> File</a></h2><p>The default configuration of FreeBSD will start up with eight virtual consoles. Thisis not a hardwired setting though, and you can easily customize your installation to bootwith more or fewer virtual consoles. The number and settings of the virtual consoles areconfigured in the <tt class="FILENAME">/etc/ttys</tt> file.</p><p>You can use the <tt class="FILENAME">/etc/ttys</tt> file to configure the virtualconsoles of FreeBSD. Each uncommented line in this file (lines that do not start with a<var class="LITERAL">#</var> character) contains settings for a single terminal orvirtual console. The default version of this file that ships with FreeBSD configures ninevirtual consoles, and enables eight of them. They are the lines that start with <varclass="LITERAL">ttyv</var>:</p><pre class="PROGRAMLISTING"># name getty type status comments#ttyv0 "/usr/libexec/getty Pc" cons25 on secure# Virtual terminalsttyv1 "/usr/libexec/getty Pc" cons25 on securettyv2 "/usr/libexec/getty Pc" cons25 on securettyv3 "/usr/libexec/getty Pc" cons25 on securettyv4 "/usr/libexec/getty Pc" cons25 on securettyv5 "/usr/libexec/getty Pc" cons25 on securettyv6 "/usr/libexec/getty Pc" cons25 on securettyv7 "/usr/libexec/getty Pc" cons25 on securettyv8 "/usr/X11R6/bin/xdm -nodaemon" xterm off secure</pre><p>For a detailed description of every column in this file and all the options you canuse to set things up for the virtual consoles, consult the <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=ttys&sektion=5"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">ttys</span>(5)</span></a> manualpage.</p></div><div class="SECT2"><h2 class="SECT2"><a id="CONSOLES-SINGLEUSER" name="CONSOLES-SINGLEUSER">3.2.5 SingleUser Mode Console</a></h2><p>A detailed description of what ``single user mode'' is can be found in <ahref="boot-init.html#BOOT-SINGLEUSER">Section 12.6.2</a>. It is worth noting that thereis only one console when you are running FreeBSD in single user mode. There are novirtual consoles available. The settings of the single user mode console can also befound in the <tt class="FILENAME">/etc/ttys</tt> file. Look for the line that starts with<var class="LITERAL">console</var>:</p><pre class="PROGRAMLISTING"># name getty type status comments## If console is marked "insecure", then init will ask for the root password# when going to single-user mode.console none unknown off secure</pre><div class="NOTE"><blockquote class="NOTE"><p><b>Note:</b> As the comments above the <var class="LITERAL">console</var> lineindicate, you can edit this line and change <var class="LITERAL">secure</var> to <varclass="LITERAL">insecure</var>. If you do that, when FreeBSD boots into single user mode,it will still ask for the <tt class="USERNAME">root</tt> password.</p><p><span class="emphasis"><i class="EMPHASIS">Be careful when changing this to <varclass="LITERAL">insecure</var></i></span>. If you ever forget the <ttclass="USERNAME">root</tt> password, booting into single user mode is a bit involved. Itis still possible, but it might be a bit hard for someone who is not very comfortablewith the FreeBSD booting process and the programs involved.</p></blockquote></div></div></div><h3 class="FOOTNOTES">Notes</h3><table border="0" class="FOOTNOTES" width="100%"><tr><td align="LEFT" valign="TOP" width="5%"><a id="FTN.AEN3628" name="FTN.AEN3628"href="consoles.html#AEN3628"><span class="footnote">[1]</span></a></td><td align="LEFT" valign="TOP" width="95%"><p>This is what <var class="LITERAL">i386</var> means. Note that even if you are notrunning FreeBSD on an Intel 386 CPU, this is going to be <var class="LITERAL">i386</var>.It is not the type of your processor, but the processor ``architecture'' that is shownhere.</p></td></tr><tr><td align="LEFT" valign="TOP" width="5%"><a id="FTN.AEN3652" name="FTN.AEN3652"href="consoles.html#AEN3652"><span class="footnote">[2]</span></a></td><td align="LEFT" valign="TOP" width="95%"><p>Startup scripts are programs that are run automatically by FreeBSD when booting. Theirmain function is to set things up for everything else to run, and start any services thatyou have configured to run in the background doing useful things.</p></td></tr><tr><td align="LEFT" valign="TOP" width="5%"><a id="FTN.AEN3679" name="FTN.AEN3679"href="consoles.html#AEN3679"><span class="footnote">[3]</span></a></td><td align="LEFT" valign="TOP" width="95%"><p>A fairly technical and accurate description of all the details of the FreeBSD consoleand keyboard drivers can be found in the manual pages of <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=syscons&sektion=4"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">syscons</span>(4)</span></a>, <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=atkbd&sektion=4"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">atkbd</span>(4)</span></a>, <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=vidcontrol&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">vidcontrol</span>(1)</span></a> and <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=kbdcontrol&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">kbdcontrol</span>(1)</span></a>. We willnot expand on the details here, but the interested reader can always consult the manualpages for a more detailed and thorough explanation of how things work.</p></td></tr></table><div class="NAVFOOTER"><hr align="LEFT" width="100%" /><table summary="Footer navigation table" width="100%" border="0" cellpadding="0"cellspacing="0"><tr><td width="33%" align="left" valign="top"><a href="basics.html"accesskey="P">Prev</a></td><td width="34%" align="center" valign="top"><a href="index.html"accesskey="H">Home</a></td><td width="33%" align="right" valign="top"><a href="permissions.html"accesskey="N">Next</a></td></tr><tr><td width="33%" align="left" valign="top">UNIX Basics</td><td width="34%" align="center" valign="top"><a href="basics.html"accesskey="U">Up</a></td><td width="33%" align="right" valign="top">Permissions</td></tr></table></div><p align="center"><small>This, and other documents, can be downloaded from <ahref="ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/">ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/</a>.</small></p><p align="center"><small>For questions about FreeBSD, read the <ahref="http://www.FreeBSD.org/docs.html">documentation</a> before contacting <<ahref="mailto:questions@FreeBSD.org">questions@FreeBSD.org</a>>.<br />For questions about this documentation, e-mail <<ahref="mailto:doc@FreeBSD.org">doc@FreeBSD.org</a>>.</small></p></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -