-->
Previous Table of Contents Next


Customizing Your pdksh

Many ways of customizing pdksh have been described in this chapter. Until now, though, the changes that you made only affected the current pdksh 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.

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

In order to set up your customization file, you must tell pdksh where to look for the initialization file. This is different than with bash. The bash 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 .profile. This file is read and all of the commands in the file are executed each time you log in to the system.

A sample of the commands that you should place in your .profile file are as follows:


export ENV=$HOME/.kshrc

EDITOR=emacs

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

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

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


Tip:  
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.

pdksh Commands

There are a lot of commands available to you in the pdksh shell, but most of them you’ll never need. Some of the most useful built-in pdksh commands are shown in Table 12.2.

Table 12.2. Useful pdksh commands and what they do.

Command What it does:

. Reads and executes the contents of the file. (This will be discussed in more detail in Chapter 14.)
alias Used to set aliases, command nicknames that can be defined by the user.
bg (Background command) forces a suspended process to continue to execute in the background.
cd (Change working directory) changes the current working directory to the directory specified.
exit Terminates the shell.
export Causes the value of a variable to be made visible to all subprocesses that belong to the current shell.
fc (Fix command) is used to edit the commands that are in the current history list.
fg (Foreground command) forces a suspended process to continue to execute in the foreground.
kill Is used to terminate another process.
pwd (Print working directory) prints to the screen the directory in which the user is currently working.
unalias Is used to remove aliases that have previously been defined using the alias command.

pdksh Variables

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

Table 12.3. Useful pdksh variables and what they

Variable name What it is:

EDITOR, FCEDIT The default editor for the fc bash command.
HISTFILE The name of the file that is used to store the command history.
HISTSIZE The size of the history list.
HOME The HOME directory of the current user.
OLDPWD The previous working directory (the one that was current before the current directory was entered).
PATH The search path that bash uses when looking for executable files.
PS1 The first level prompt that is displayed on the command line.
PS2 The second level prompt that is displayed when a command is expecting more input.
PWD The current working directory.
SECONDS The number of seconds that have elapsed since the current bash session was started.

Summary

We’ve looked at many of the features of the Public Domain Korn Shell (pdksh). It is similar to the Bourne Again Shell in many aspects, but it does add some new utilities.

In the next chapter, we look at tcsh, 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:

Learn about shell programming and how you can use it to make your experience with bash more powerful, see Chapter 14, “Shell Programming.”
Learn about using editors to create and edit files, see Chapter 16, “Text Editors: vi and emacs.”
Learn about using the X GUI, see Chapter 22, “Installing and Configuring XFree86.”


Previous Table of Contents Next