UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 1.7 Power Grows on You Chapter 1
Introduction
Next: 1.9 Which Shell Am I Running?
 

1.8 There Are Many Shells

With most operating systems, the command intepreter is built in; it is an integral part of the operating system. With UNIX, your command interpreter is just another program. Traditionally, a command interpreter is called a "shell," perhaps because it protects you from the underlying kernel - or because it protects the kernel from you!

Several different shells are available: you are free to choose the one that best suits your interests or your application. The most common ones are:

sh

The Bourne shell (named after its creator, Steve Bourne). This is the oldest of the current UNIX shells and is available on most UNIX systems. (Some systems have replaced sh with a newer shell, like ksh or bash, that has the features of sh and more.) It is a bit primitive and lacks job control features (the ability to move jobs from the foreground to the background). Most UNIX users consider the Bourne shell superior for shell programming or writing command files.

csh

The C shell. It was developed at Berkeley as part of their UNIX implementation and has been by far the most popular shell for interactive use. You will occasionally find a System V UNIX where the C shell isn't available, but this is very rare. It has a lot of nice features that aren't available in the Bourne shell, including job control (12.8) and history (11.2) (the ability to repeat commands that you have already given). However, while you won't have trouble with normal usage, it isn't hard for a shell programmer to push the C shell to its limits (47.2). There are a lot of hidden bugs.

ksh

The Korn shell (also named after its creator, David Korn). The Korn shell is compatible with the Bourne shell, but has most of the C shell's features plus some completely new features, like history editing (11.13): the ability to recall old commands and edit them before executing them. It is also more reliable than csh. The Korn shell is a standard part of UNIX System V Release 4; it has also been included in some other UNIX implementions.

bash

The "Bourne-again" shell developed by the Free Software Foundation (52.9). bash (8.2) is fairly similar to the Korn shell. It has many of the C shell's features, plus history editing and a built-in help command.

tcsh

You may run into some extended versions of the C shell like tcsh. tcsh (8.3) works like the original C shell - but with more features, and fewer mis-features.

There are also a few third-party shells that serve special purposes, like emulating the VAX/VMS command language (DCL). I don't know if there is a DOS-lookalike shell available, but there probably is. Why you would want it is another question: all of the standard UNIX shells do a lot more than the DOS command interpreter. Furthermore, I like to discourage UNIX users from pretending that UNIX is something else. You are going to be spending a lot of time using UNIX: you will be better off learning it properly than trying to make it look like some other operating system.

In this book, we'll stick to the C shell and bash for interactive use. Because bash and ksh can read scripts written for the original Bourne shell, we use sh for shell programming.

Where we talk about "the Bourne Shell" or sh, it's usually a safe bet that the information applies to bash and ksh too. In the same way, "the C shell" generally also means tcsh-and, in some cases, bash as well. Just because bash, ksh and tcsh have the features of the shells they came from, though, it isn't safe to assume that their features are in the original csh or sh too.

If you're new to UNIX, don't worry about keeping track of all these shells. In this book, we talk mostly about the C and Bourne shells. Those two shell "styles" are all you really need to know at the start. Later, you can learn and appreciate what's been added to ksh, tcsh, and bash.

- ML, JP


Previous: 1.7 Power Grows on You UNIX Power ToolsNext: 1.9 Which Shell Am I Running?
1.7 Power Grows on You Book Index1.9 Which Shell Am I Running?

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System