Many different Unix shells are available. This quick reference describes the three most popular shells:
The Bourne (or standard) shell, the most compact shell and also the simplest.
The Korn shell, a superset of the Bourne shell that lets you edit 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 book as ksh88 and ksh93 respectively.
The C shell, which uses C-like syntax and is more convenient for the interactive user than the Bourne shell.
Most systems have more than one shell, and people will often use the Bourne shell for writing shell scripts and another shell for interactive use.
The /etc/passwd file determines which shell takes effect during your interactive Unix session. When you log in, the system checks your entry in /etc/passwd. The last field of each entry names a program to run as the default shell.[4] For example:
[4]On Solaris or other networked Unix systems, this information may come from NIS or NIS+. Usually, your system administrator will handle this for you; just don't be surprised if your login name doesn't appear in /etc/passwd.
If the program name is: | Your shell is the: |
---|---|
/bin/sh | Bourne shell |
/bin/rsh | Restricted Bourne shell |
/bin/jsh | Bourne shell, including job control |
/bin/ksh | Korn shell |
/usr/dt/bin/dtksh | The Desktop Korn shell, a version of ksh93 (Solaris only) |
/bin/rksh | Restricted Korn shell |
/bin/csh | C shell |
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:
$ exec ksh
Note that on most systems, rsh is the “remote shell” for executing commands on a remote system across a network. On some systems, though, rsh is indeed the restricted shell, and remsh is the remote shell. Check your local documentation.
If you are new to Unix, picking a shell may be a bewildering question. Before ksh was commonly available, the general advice was to use csh for interactive use (because it supported job control and had other features that made it a better interactive shell than the Bourne shell), but to use the Bourne shell for scripting (because it is a more powerful programming language, and more universally available).
Today, ksh is widely available; it is upwardly compatible with the Bourne shell as a programming language, and it has all the interactive capabilities of csh, and more. If it is available, it is probably your best choice.
Copyright © 2003 O'Reilly & Associates. All rights reserved.