HP-UX gives you your choice of several different shells. This section
discusses the POSIX, Bourne, and Key Shells. Details on the C shell
can be found in the Shells: User's Guide.
Each of these shells has different characteristics, and you can increase
the speed and efficiency with which you interact with HP-UX if you learn
to use some of the built-in features of the shell of your choice.
With the POSIX and Key Shells, you can edit your
command line and recall previous commands. Your shell
environment can be "customized" using shell variables and login scripts.
Using simple commands, you can determine which shell you are running
or change your shell temporarily or permanently. See “Determining Your Login Shell” for a listing of both the file name for each shell
and the default system prompt.
 |
 |  |
 |
 | NOTE:
As of the HP-UX 10.0 release, the OSF POSIX Shell replaces
the Korn Shell and Bourne Shell.
Thus, /usr/bin/sh will be the POSIX Shell, and /usr/bin/ksh
will be linked to /usr/bin/sh.
However, /usr/old/bin/sh will contain the Bourne Shell for
those users who still need it.
|
 |
 |  |
 |
The following table lists features that may help you decide
which shell to use:
Table 16-1 Comparison of Shell Features
|
Features
| Description
| POSIX\Key
| Bourne
| C
|
|---|
| Allows commands to be stored in a buffer, then modified and reused.
| yes
| no
| yes
|
| Ability to modify the current or previous command lines with a text editor.
| yes
| no
| no
|
| Ability to automatically finish typing file names in command lines.
| yes
| no
| yes
|
| Lets you rename commands, automatically include command options,
or abbreviate long command lines.
| yes
| no
| yes
|
| A security feature providing a controlled environment with
limited capabilities.
| yes
| yes
| no
|
| Tools for tracking and accessing processes that run in the
background.
| yes
| no
| yes
|
Determining Your Login Shell |
 |
The command echo $SHELL displays the file
name of the shell you entered when you logged in.
The echo command displays the contents or value
of a variable named SHELL. The SHELL variable contains the
name of the file that contains the shell program that you are
running. In this example, it is /usr/bin/sh, the file that contains the
code for the POSIX Shell.
The following table lists both the file name of each shell and the
default system prompt. (The superuser prompt for each is #.)
Table 16-2 Shell File Names and Default Prompts
| Shell | File Name | Prompt
|
|---|
| POSIX
| /usr/bin/sh | $ |
| Key
| /usr/bin/keysh | $ |
| C
| /usr/bin/csh | % |
| /usr/old/bin/sh | $ |
Korn
(replaced by
POSIX shell)
| /usr/bin/ksh (linked to /usr/bin/sh)
| $ |
Temporarily Changing Your Shell |
 |
Unless you are in a restricted shell, you can temporarily change your shell
by using this command:
where shell_name is the name of the shell (for example, sh,
or csh). Temporarily changing your shell lets you experiment in
other shells. By typing the name of the shell you want to run, you
invoke (enter) that shell, and the correct prompt is displayed.
To return to your original shell, type either exit or
CTRL-D.
The following example begins in the POSIX Shell, enters the C Shell,
and returns to the POSIX Shell:
$ csh Enter C Shell.
% ps Execute the ps command.
PID TTY TIME COMMAND
6009 tty01 0:00 csh Notice that both the C
5784 tty01 0:00 sh and POSIX Shell
6010 tty01 0:00 ps processes are running.
% exit Exit C Shell.
$ cursor POSIX Shell returns.
|
Permanently Changing Your Shell |
 |
To permanently change your login shell (the default shell you get
when you log in), use the chsh (change shell)
command:
chsh username full_shell_name
|
where username is your user name and shell_path_name is the
full path name (for example, /usr/bin/sh) of the shell you want as your
default. “Determining Your Login Shell” contains the full path names for each of
the shells. After you use the chsh command, you must log out and
log in again for the change to take effect. For example, if terry
changes the default login shell to the C Shell, the command reads:
$ chsh terry /usr/bin/csh
% cursor
|