February 16, 2019

Sobell on the Bourne Again Shell and the Linux Command Line - page 2

The Fate of the Command Line

  • November 21, 2005
  • By Ibrahim Haddad

LP: Would you discuss the Bourne Again shell and explain how it compares to the original Bourne Shell?

The shell is the command line interpreter -- it parses the command lines you enter and calls the programs you request, passing to the program the arguments you entered on the command line. The shell is also a high-level programming language. The Bourne Again Shell, or bash, is the default shell on many Linux systems. Other shells are included with most distributions and even more are available for download.

The Bourne Again Shell, written by the GNU project, is a souped up version of the original Bourne Shell (sh), the first shell available under UNIX as it was released by AT&T. I used to recommend that readers consider using the C Shell (csh) as their interactive shell because it has some important features that are not available in the original Bourne Shell. Today bash has all those features and then some, including command completion, history (so you can edit and repeat previous commands), and job control (allows you to move jobs between the foreground and background). And of course you can write shell scripts (batch files) using bash.

Many Linux system shell scripts start with the line #!/bin/sh. This line causes the script to run under the sh program, which is not the original Bourne Shell, but a link to bash.

"Because of its long and successful history, the original Bourne Shell has been used to write many of the shell scripts that help manage UNIX systems. Some of these scripts appear in Linux as Bourne Again Shell scripts. Although the Bourne Again Shell includes many extensions and features not found in the original Bourne Shell, bash maintains compatibility with the original Bourne Shell so you can run Bourne Shell scripts under bash. On UNIX systems the original Bourne Shell is named sh. On Linux systems sh is a symbolic link to bash ensuring that scripts that require the presence of the Bourne Shell still run. When called as sh, bash does its best to emulate the original Bourne Shell."

LP: Would you recommend that someone new to Linux learn the Bourne Again Shell or the TC Shell?

If you are a hard-core C Sheller, go ahead and use the TC Shell (tcsh). Otherwise I would stick with bash. Almost all administration shell scripts that control a Linux system are written to be run by bash, so if you learn bash you will be able to understand and modify those scripts more easily.

Most Popular LinuxPlanet Stories