Running Commands from the Shell
computer software
Running Commands from the Shell Running Commands from the Shell
Running Commands from the Shell   Home | Site Map | About Us | Products | Services | News | Contact Us | Links Running Commands from the Shell
Running Commands from the Shell Running Commands from the Shell

Copyright © 2009

Linux® Bible


You might want to choose a different shell to use because:
You are used to using UNIX System V systems (often ksh by default) or Sun Microsystems
and other Berkeley UNIX­based distributions (frequently csh by default), and you are
more comfortable using default shells from those environments.
You want to run shell scripts that were created for a particular shell environment, and you
need to run the shell for which they were made so you can test or use those scripts.
You might simply prefer features in one shell over those in another. For example, a mem-
ber of my Linux Users Group prefers ksh over bash because he doesn't like the way
aliases are always set up with bash.
Although most Linux users have a preference for one shell or another, when you know how to use
one shell, you can quickly learn any of the others by occasionally referring to the shell's man page
(for example, type man bash). Most people use bash just because they don't have a particular rea-
son for using a different shell. In Chapter 4, you learn how to assign a different default shell for a
user. The following sections introduce several of the most common shells available with Linux.
Using bash (and Earlier sh) Shells
As mentioned earlier, the name bash is an acronym for Bourne Again Shell, acknowledging the
roots of bash coming from the Bourne shell (
sh
command) created by Steve Bourne at AT&T Bell
Labs. Brian Fox of the Free Software Foundation created bash, under the auspices of the GNU
Project. Development was later taken over by Chet Ramey at Case Western Reserve University.
Bash includes features originally developed for sh and ksh shells in early UNIX systems, as well as
some csh features. Expect bash to be the default shell in whatever Linux system you are using, with
the exception of some specialized Linux systems (such as those run on embedded devices or run
from a floppy disk) that may require a smaller shell that needs less memory and entails fewer fea-
tures. Most of the examples in this chapter are based on the bash shell.
The bash shell is worth knowing not only because it is the default in most installations,
but because it is the one tested in most Linux certification exams.
Bash can be run in various compatibility modes so that it behaves like different shells. It can be run
to behave as a Bourne shell (
bash +B
) or as a POSIX-compliant shell (type
bash --posix
), for
example, enabling it to read configuration files that are specific to those shells and run initialization
shell scripts written directly for those shells, with a greater chance of success.
All of the Linux distributions included with this book use bash as the default shell, with the excep-
tion of some bootable Linux distributions, which use the ash shell instead.
Using tcsh (and Earlier csh) Shells
The tcsh shell is the open source version of the C shell (csh). The csh shell was created by Bill Joy
and used with most Berkeley UNIX systems (such as those produced by Sun Microsystems) as the
TIP
TIP
39
Running Commands from the Shell
2