📄 555-558.html
字号:
<HTML>
<HEAD>
<TITLE>Linux in Plain English:Linux Shells</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=1558285423//-->
<!--TITLE=Linux in Plain English//-->
<!--AUTHOR=Patrick Volkerding//-->
<!--AUTHOR=Kevin Reichard//-->
<!--PUBLISHER=IDG Books Worldwide, Inc.//-->
<!--IMPRINT=M & T Books//-->
<!--CHAPTER=6//-->
<!--PAGES=555-558//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="../ch05/547-554.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="../ch07/559-561.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H2><A NAME="Heading1"></A><FONT COLOR="#000077">Chapter 6<BR>Linux Shells
</FONT></H2>
<P>You can’t run Linux without running a <B>shell</B>, a tool that interacts with you and provides a way to directly communicate with the core of the operating system. What you assume is being done by the operating system is most often being done by the shell: It accepts your commands, interprets them, and passes them along to the core operating system; it provides its own set of commands (some of which were covered in Chapter 5 as operating-system commands; it’s really a distinction without difference); and it provides its own scripting mechanisms.</P>
<P>Most Linux distributions include at least six or seven shells, but people usually stick with the default Bourne Again Shell (bash) from the Free Software Foundation, a clone of the popular Bourne shell found on most UNIX systems. In addition, many users switch to the C shell (csh) or a scaled-down version of the C shell, tcsh. (When you install your Linux distribution, you’re typically asked which shells you want installed on your system. A slew of Linux shellsare available, including ash and zsh.) To see which shells are installed on your system, use the following command line:</P>
<!-- CODE SNIP //-->
<PRE>
$ chsh -l
/bin/sh
/bin/bash
/bin/csh
/bin/tcsh
...
</PRE>
<!-- END CODE SNIP //-->
<P>To change your login shell, use one of the following command lines:
</P>
<!-- CODE SNIP //-->
<PRE>
$ chsh -s /bin/csh
</PRE>
<!-- END CODE SNIP //-->
<P>or
</P>
<!-- CODE SNIP //-->
<PRE>
$ exec /bin/csh
</PRE>
<!-- END CODE SNIP //-->
<P>We’re not going to spend a lot of time on shells; there’s more than enough online documentation for them, and there are more than enough books on the market about shells and their usage. Instead, we’ll spend some time covering shell variables.
</P>
<H3><A NAME="Heading2"></A><FONT COLOR="#000077">Shell Variables</FONT></H3>
<P>These variables are set by the shell. They are used in a wide variety of circumstances, but typically they’re involved in shell scripts.
</P>
<TABLE WIDTH="100%"><TR>
<TH WIDTH="25%" ALIGN="LEFT">Variable
<TH WIDTH="75%" ALIGN="LEFT">Explanation
<TR>
<TD VALIGN="TOP">IFS
<TD>The Internal Field Separator that is used for word splitting after expansion and to split lines into words with the read built-in command. The default value is <B>space-tab-newline</B>’.
<TR>
<TD VALIGN="TOP">PATH
<TD>The search path for commands. It is a colon-separated list of directories in which the shell looks for commands. The default path is system-dependent and is set by the administrator who installs bash.
<TR>
<TD VALIGN="TOP">HOME
<TD>The home directory of the current user; the default argument for the <B>cd</B> command.
<TR>
<TD VALIGN="TOP">CDPATH
<TD>The search path for the <B>cd</B> command. This is a colon-separated list of directories in which the shell looks for destination directories specified by the <B>cd</B> command.
<TR>
<TD VALIGN="TOP">ENV
<TD>If this parameter is set when bash is executing a shell script, its value is interpreted as a filename containing commands to initialize the shell, as in <B>.bashrc</B>. The value of ENV is subjected to parameter expansion, command substitution, and arithmetic expansion before being interpreted as a pathname. PATH is not used to search for the resultant pathname.
<TR>
<TD VALIGN="TOP">MAIL
<TD>If this parameter is set to a filename and the MAILPATH variable is not set, <B>bash</B> informs the user of the arrival of mail in the specified file.
<TR>
<TD VALIGN="TOP">MAILCHECK
<TD>Specifies how often (in seconds) <B>bash</B> checks for mail. The default is 60 seconds. When it is time to check for mail, the shell does so before prompting. If this variable is not set, the shell disables mail checking.
<TR>
<TD VALIGN="TOP">MAILPATH
<TD>A colon-separated list of pathnames to be checked for mail. The message to be printed may be specified by separating the pathname from the message with <B>?</B>.
<TR>
<TD VALIGN="TOP">MAIL_WARNING
<TD>If set, and a file that <B>bash</B> is checking for mail has been accessed
<TR>
<TD>
<TD>since the last time it was checked, the message <I>The mail in mailfile has been read</I> is printed.
<TR>
<TD>PS1
<TD>Sets the primary prompt. The default value is <B>bash\$.</B>
<TR>
<TD VALIGN="TOP">PS2
<TD>Sets the secondary prompt, used by many applications to provide input. The default value is <B>>.</B>
<TR>
<TD>PS3
<TD>Set the prompt for the <B>select</B> command.
<TR>
<TD VALIGN="TOP">PS4
<TD>Sets the value of the character used before commands in an execution trace. The default is <B>+</B>.
<TR>
<TD VALIGN="TOP">HISTSIZE
<TD>Sets the number of commands to remember in the command history. The default is 500.
<TR>
<TD VALIGN="TOP">HISTFILE
<TD>Sets the name of the file where command history is saved. The default is <B>[sim]/.bash_history</B>.
<TR>
<TD VALIGN="TOP">HISTFILESIZE
<TD>Sets the maximum number of lines in the history file. The default value is 500.
<TR>
<TD VALIGN="TOP">IGNOREEOF
<TD>Controls the action of the shell on receipt of an EOF character as the sole input. If set, the value is the number of consecutive EOF characters typed as the first characters on an input line before <B>bash</B> exits. If the variable exists but does not have a numeric value,or has no value, the default value is 10. If it does not exist, EOF signifies the end of input to the shell. This is only in effect for interactive shells.
<TR>
<TD VALIGN="TOP">TMOUT
<TD>If set to a value greater than zero, the value is interpreted as the number of seconds to wait for input after issuing the primary prompt. <B>bash</B> terminates after waiting for that number of seconds if input does not arrive.
<TR>
<TD VALIGN="TOP">FIGNORE
<TD>A colon-separated list of suffixes to ignore when performing filename completion. A filename whose suffix matches one of the entries in FIGNORE is excluded from the list of matched filenames. A sample value is <B>``.o:[sim]’’</B>.
</TABLE>
<P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="../ch05/547-554.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="../ch07/559-561.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 + -