239-242.html

来自「linux-unix130.linux.and.unix.ebooks130 l」· HTML 代码 · 共 170 行

HTML
170
字号
<HTML>

<HEAD>

<TITLE>Linux Unleashed, Third Edition:pdksh</TITLE>

<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->




<!--ISBN=0672313723//-->

<!--TITLE=Linux Unleashed, Third Edition//-->

<!--AUTHOR=Tim Parker//-->

<!--PUBLISHER=Macmillan Computer Publishing//-->

<!--IMPRINT=Sams//-->

<!--CHAPTER=12//-->

<!--PAGES=239-242//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="236-238.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="../ch13/243-246.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<H3><A NAME="Heading13"></A><FONT COLOR="#000077">Customizing Your pdksh</FONT></H3>

<P>Many ways of customizing <TT>pdksh</TT> have been described in this chapter. Until now, though, the changes that you made only affected the current <TT>pdksh</TT> session. As soon as you quit pdksh, all of the customizations that you made were lost. However, there is a way of making the customizations more permanent.</P>

<P>This is done by storing all of your customizations in a <TT>pdksh</TT> initialization file. Users can put commands into this file that they want to be executed each and every time <TT>pdksh</TT> is started. Examples of commands that are typically found in this file are aliases and initializations of variables (such as the prompts).</P>

<P>In order to set up your customization file, you must tell <TT>pdksh</TT> where to look for the initialization file. This is different than with <TT>bash</TT>. The <TT>bash</TT> shell automatically knows where to look for its customization file. To tell pdksh where to look for the customization file, you need to create a file in your home directory called <TT>.profile</TT>. This file is read and all of the commands in the file are executed each time you log in to the system.</P>

<P>A sample of the commands that you should place in your <TT>.profile</TT> file are as follows:</P>

<!-- CODE SNIP //-->

<PRE>

export ENV=&#36;HOME/.kshrc

EDITOR=emacs

</PRE>

<!-- END CODE SNIP //-->

<P>The first line in the <TT>.profile</TT> file sets the <TT>ENV</TT> variable. This is the variable that <TT>pdksh</TT> looks at to find the initialization file that it should use. If you plan to customize <TT>pdksh</TT>, you should tell <TT>pdksh</TT> to look for a file in your home directory. The filename <TT>.kshrc</TT> is often used as the <TT>pdksh</TT> initialization filename, but you can pick another name if you want.</P>

<P>If you are not planning to customize <TT>pdksh</TT>, you can set the <TT>ENV</TT> variable to be equal to the system default <TT>pdksh</TT> initialization file. This file is in the <TT>/etc</TT> directory and is called <TT>ksh.kshrc</TT>.</P>

<P>The second line in the <TT>.profile file sets the EDITOR</TT> variable. This is used by the <TT>.kshrc</TT> initialization file to determine what type of command-line editing commands to use for your session. If you prefer to use <TT>vi</TT> command-line editing, you can set this variable to be equal to <TT>vi</TT>.</P>

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR><B>Tip:&nbsp;&nbsp;</B><BR>Instead of copying the file to your home directory, you can create a new file in your home directory that calls the system default file, and then add customizations afterward.<HR></FONT>

</BLOCKQUOTE>

<H3><A NAME="Heading14"></A><FONT COLOR="#000077">pdksh Commands</FONT></H3>

<P>There are a lot of commands available to you in the <TT>pdksh</TT> shell, but most of them you&#146;ll never need. Some of the most useful built-in <TT>pdksh</TT> commands are shown in Table 12.2.</P>

<TABLE WIDTH="100%"><CAPTION ALIGN=LEFT><B>Table 12.2.</B> Useful <TT>pdksh</TT> commands and what they do.

<TR>

<TH COLSPAN="2"><HR>

<TR>

<TH WIDTH="20%" ALIGN="LEFT">Command

<TH WIDTH="80%" ALIGN="LEFT">What it does:

<TR>

<TH COLSPAN="2"><HR>

<TR>

<TD VALIGN="TOP"><TT>.</TT>

<TD>Reads and executes the contents of the file. (This will be discussed in more detail in Chapter 14.)

<TR>

<TD VALIGN="TOP"><TT>alias</TT>

<TD>Used to set aliases, command nicknames that can be defined by the user.

<TR>

<TD VALIGN="TOP"><TT>bg</TT>

<TD>(Background command) forces a suspended process to continue to execute in the background.

<TR>

<TD VALIGN="TOP"><TT>cd</TT>

<TD>(Change working directory) changes the current working directory to the directory specified.

<TR>

<TD><TT>exit</TT>

<TD>Terminates the shell.

<TR>

<TD VALIGN="TOP"><TT>export</TT>

<TD>Causes the value of a variable to be made visible to all subprocesses that belong to the current shell.

<TR>

<TD VALIGN="TOP"><TT>fc</TT>

<TD>(Fix command) is used to edit the commands that are in the current history list.

<TR>

<TD VALIGN="TOP"><TT>fg</TT>

<TD>(Foreground command) forces a suspended process to continue to execute in the foreground.

<TR>

<TD><TT>kill</TT>

<TD>Is used to terminate another process.

<TR>

<TD VALIGN="TOP"><TT>pwd</TT>

<TD>(Print working directory) prints to the screen the directory in which the user is currently working.

<TR>

<TD VALIGN="TOP"><TT>unalias</TT>

<TD>Is used to remove aliases that have previously been defined using the alias command.

<TR>

<TD COLSPAN="2"><HR>

</TABLE>

<H3><A NAME="Heading15"></A><FONT COLOR="#000077">pdksh Variables</FONT></H3>

<P>Some of the most useful <TT>pdksh</TT> variables are listed in Table 12.3, including the variable name, a short description, and default value (if one exists).</P>

<TABLE WIDTH="100%"><CAPTION ALIGN=LEFT><B>Table 12.3.</B> Useful <TT>pdksh</TT> variables and what they

<TR>

<TH COLSPAN="2"><HR>

<TR>

<TH WIDTH="25%" ALIGN="LEFT">Variable name

<TH WIDTH="75%" ALIGN="LEFT">What it is:

<TR>

<TH COLSPAN="2"><HR>

<TR>

<TD><TT>EDITOR, FCEDIT</TT>

<TD>The default editor for the <TT>fc bash</TT> command.

<TR>

<TD><TT>HISTFILE</TT>

<TD>The name of the file that is used to store the command history.

<TR>

<TD><TT>HISTSIZE</TT>

<TD>The size of the history list.

<TR>

<TD><TT>HOME</TT>

<TD>The <TT>HOME</TT> directory of the current user.

<TR>

<TD VALIGN="TOP"><TT>OLDPWD</TT>

<TD>The previous working directory (the one that was current before the current directory was entered).

<TR>

<TD><TT>PATH</TT>

<TD>The search path that <TT>bash</TT> uses when looking for executable files.

<TR>

<TD><TT>PS1</TT>

<TD>The first level prompt that is displayed on the command line.

<TR>

<TD VALIGN="TOP"><TT>PS2</TT>

<TD>The second level prompt that is displayed when a command is expecting more input.

<TR>

<TD><TT>PWD</TT>

<TD>The current working directory.

<TR>

<TD VALIGN="TOP"><TT>SECONDS</TT>

<TD>The number of seconds that have elapsed since the current <TT>bash</TT> session was started.

<TR>

<TH COLSPAN="2"><HR>

</TABLE>

<H3><A NAME="Heading16"></A><FONT COLOR="#000077">Summary</FONT></H3>

<P>We&#146;ve looked at many of the features of the Public Domain Korn Shell (<TT>pdksh</TT>). It is similar to the Bourne Again Shell in many aspects, but it does add some new utilities.</P>

<P>In the next chapter, we look at <TT>tcsh</TT>, a version of the C shell that is available with Linux. After you have seen the features and the way you use the three shells, you should be able to decide which shell is best for you to use on a regular basis. Of course, you can use any shell at any time by simply typing its name. You may want to learn about other subjects before moving on to the C shell. To:</P>

<DL>

<DD>Learn about shell programming and how you can use it to make your experience with <TT>bash</TT> more powerful, see Chapter 14, &#147;Shell Programming.&#148;

<DD>Learn about using editors to create and edit files, see Chapter 16, &#147;Text Editors: <TT>vi</TT> and <TT>emacs</TT>.&#148;

<DD>Learn about using the X GUI, see Chapter 22, &#147;Installing and Configuring XFree86.&#148;

</DL>

<P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="236-238.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="../ch13/243-246.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>





</td>
</tr>
</table>

<!-- begin footer information -->





</body></html>

⌨️ 快捷键说明

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