3.6 Types of shells


Next: 3.7 Wildcards Up: 3 Linux Tutorial Previous: 3.5 Exploring the File

  As I have mentioned too many times before, UNIX is a multitasking, multiuser operating system. Multitasking is very useful, and once you get used to it, you’ll use it all of the time. Before long, you’ll be able to run programs in the « background », switch between multiple tasks, and « pipeline » programs together to achieve complicated results with a single command.

Many of the features we’ll be covering in this section are features provided by the shell itself. Be careful not to confuse UNIX (the actual operating system) with the shell—the shell is just an interface to the underlying system. The shell provides a great deal of functionality on top of UNIX itself.

  The shell is not only an interpreter for your interactive commands, which you type at the prompt. It is also a powerful programming language, which allows you to write shell scripts, to « batch » several shell commands together in a file. MS-DOS users will recognize the similarity to « batch files ». Use of shell scripts is a very powerful tool, which will allow you to automate and expand your usage of UNIX. See Section 3.13.1 for more information.

            There are several types of shells in the UNIX world. The two major types are the « Bourne shell » and the « C shell ». The Bourne shell uses a command syntax like the original shell on early UNIX systems, such as System III. The name of the Bourne shell on most UNIX systems is /bin/sh (where sh stands for « shell »). The C shell (not to be confused with sea shell) uses a different syntax, somewhat like the programming language C, and on most UNIX systems is named /bin/csh.

READ  A Brief History of the 'rm' and 'rmdir' commands LG #49

              Under Linux, there are several variations of these shells available. The two most commonly used are the Bourne Again Shell, or « Bash » (/bin/bash), and Tcsh (/bin/tcsh). Bash is a form of the Bourne shell with many of the advanced features found in the C shell. Because Bash supports a superset of the Bourne shell syntax, any shell scripts written in the standard Bourne shell should work with Bash. For those who prefer to use the C shell syntax, Linux supports Tcsh, which is an expanded version of the original C shell.

The type of shell that you decide to use is mostly a religious issue. Some folks prefer the Bourne shell syntax with the advanced features of Bash, and some prefer the more structured C shell syntax. As far as normal commands, such as cp and ls, are concerned, the type of shell you’re using doesn’t matter—the syntax is the same. Only when you start to write shell scripts or use some of the advanced features of the shell do the differences between shell types begin to matter.

As we’re discussing some of the features of the shell, below, we’ll note those differences between Bourne and C shells. However, for the purposes of this manual, most of those differences are minimal. (If you’re really curious at this point, read the man pages for bash and tcsh).


Next: 3.7 Wildcards Up: 3 Linux Tutorial Previous: 3.5 Exploring the File

Matt Welsh
mdw@sunsite.unc.edu