📄 ch03_03.htm
字号:
<html><head><title>Shell Flavors (UNIX in a Nutshell: System V Edition)</title><link rel="stylesheet" type="text/css" href="../style/style1.css" /><meta name="DC.Creator" content="Arnold Robbins" /><meta name="DC.Format" content="text/xml" scheme="MIME" /><meta name="DC.Language" content="en-US" /><meta name="DC.Publisher" content="O'Reilly & Associates, Inc." /><meta name="DC.Source" scheme="ISBN" content="1-56592-427-4" /><meta name="DC.Subject.Keyword" content="stuff" /><meta name="DC.Title" content="UNIX in a Nutshell: System V Edition" /><meta name="DC.Type" content="Text.Monograph" /></head><body bgcolor="#ffffff"><img src="gifs/smbanner.gif" usemap="#banner-map" border="0" alt="Book Home" /><map name="banner-map"><area shape="rect" coords="1,-2,616,66" href="index.htm" alt="Book Title" /><area shape="rect" coords="629,-11,726,25" href="jobjects/fsearch.htm" alt="Search this book" /></map><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="ch03_02.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0" /></a></td><td align="center" valign="top" width="228" /><td align="right" valign="top" width="228"><a href="ch03_04.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0" /></a></td></tr></table></div><h2 class="sect1">3.3. Shell Flavors</h2><p><a name="IXT-3-122631" />Many different Unix shells are available.This quick reference describes the three most popular shells:</p><ul><li><p><a name="IXT-3-122632" />The Bourne (or standard) shell, the most compact shell and alsothe simplest.</p></li><li><p><a name="IXT-3-122633" /><a name="IXT-3-122634" />The Korn shell, a superset of the Bourne shell that lets youedit the command line.There are in fact two commonly available versions of the Korn shell,distinguished by the year they were released,and referred to in this bookas <tt class="literal">ksh88</tt> and <tt class="literal">ksh93</tt> respectively.</p></li><li><p><a name="IXT-3-122635" />The C shell, which uses C-like syntax and is more convenient for the interactiveuser than the Bourne shell.</p></li></ul><p>Most systems have more than one shell, and people will oftenuse the Bourne shell for writing shell scripts andanother shell for interactive use.</p><p><a name="IXT-3-122636" />The <tt class="literal">/etc/passwd</tt> file determines which shell takes effectduring your interactive Unix session.When you log in, the system checksyour entry in <tt class="literal">/etc/passwd</tt>. The last field of each entrynames a program to run as the default shell.<a href="#FOOTNOTE-4">[4]</a>For example:</p><blockquote class="footnote"><a name="FOOTNOTE-4" /><p> [4]On Solaris or other networked Unix systems, this information maycome from NIS or NIS+.Usually, your system administrator will handle this for you; justdon't be surprised if your login name doesn'tappear in <tt class="literal">/etc/passwd</tt>.</p></blockquote><table border="1" cellpadding="3"><tr><th><em class="emphasis">If the program name is:</em></th><th><em class="emphasis">Your shell is the:</em></th></tr><tr><td><tt class="literal">/bin/sh</tt></td><td>Bourne shell</td></tr><tr><td><tt class="literal">/bin/rsh</tt></td><td>Restricted Bourne shell</td></tr><tr><td><tt class="literal">/bin/jsh</tt></td><td>Bourne shell, including job control</td></tr><tr><td><tt class="literal">/bin/ksh</tt></td><td>Korn shell</td></tr><tr><td><tt class="literal">/usr/dt/bin/dtksh</tt></td><td><p>The Desktop Korn shell, a version of <tt class="literal">ksh93</tt>(Solaris only)</p></td></tr><tr><td><tt class="literal">/bin/rksh</tt></td><td>Restricted Korn shell</td></tr><tr><td><tt class="literal">/bin/csh</tt></td><td>C shell</td></tr></table><p><p>You can change to another shell by typing the program name at the command line.For example, to change from the Bourne shell to the Korn shell, type:</p><blockquote><pre class="code">$ <tt class="userinput"><b>exec ksh</b></tt></pre></blockquote><p><a name="IXT-3-122637" /><a name="IXT-3-122638" />Note that on most systems, <tt class="literal">rsh</tt> is the “remote shell”for executing commands on a remote system across a network.On some systems, though, <tt class="literal">rsh</tt> is indeed the restrictedshell, and <tt class="literal">remsh</tt> is the remote shell.Check your local documentation.</p><a name="unut-ch-3-sect-3.1" /><div class="sect2"><h3 class="sect2">3.3.1. Which Shell Do I Want?</h3><p>If you are new to Unix, picking a shell may be a bewildering question.Before <tt class="literal">ksh</tt> was commonly available, the general advicewas to use <tt class="literal">csh</tt> for interactive use(because it supported job control and had otherfeatures that made it a better interactive shell than the Bourne shell),but to use the Bourne shell for scripting (because it is a morepowerful programming language, and more universally available).</p><p>Today, <tt class="literal">ksh</tt> is widely available; it is upwardly compatiblewith the Bourne shell as a programming language,and it has all the interactive capabilities of <tt class="literal">csh</tt>,and more.If it is available, it is probably your best choice.</p></div><hr width="684" align="left" /><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="ch03_02.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0" /></a></td><td align="center" valign="top" width="228"><a href="index.htm"><img src="../gifs/txthome.gif" alt="Home" border="0" /></a></td><td align="right" valign="top" width="228"><a href="ch03_04.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0" /></a></td></tr><tr><td align="left" valign="top" width="228">3.2. Purpose of the Shell</td><td align="center" valign="top" width="228"><a href="index/index.htm"><img src="../gifs/index.gif" alt="Book Index" border="0" /></a></td><td align="right" valign="top" width="228">3.4. Common Features</td></tr></table></div><hr width="684" align="left" /><img src="../gifs/navbar.gif" usemap="#library-map" border="0" alt="Library Navigation Links" /><p><p><font size="-1"><a href="copyrght.htm">Copyright © 2003</a> O'Reilly & Associates. All rights reserved.</font></p><map name="library-map"><area shape="rect" coords="1,0,88,96" href="../index.htm"><area shape="rect" coords="90,0,165,96" href="../upt/index.htm"><area shape="rect" coords="168,1,253,107" href="../mac/index.htm"><area shape="rect" coords="255,0,335,97" href="../korn/index.htm"><area shape="rect" coords="337,0,415,109" href="../unixnut/index.htm"><area shape="rect" coords="417,0,512,122" href="../sedawk/index.htm"><area shape="rect" coords="514,0,605,105" href="../lunix/index.htm"><area shape="rect" coords="611,2,694,121" href="../vi/index.htm"></map></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -