The job of the shell

We need to have a quick look at what the shell actually does. The main functions of the shell are described below.

Command Interpreter

The shell interprets commands. A command typed in at the prompt will know how to be executed because the shell will use its PATH to search for the command.

Typing cd, the command interpreter knows this is a built-in command , and will not search for it in the PATH.

Typing pwd, it understands that it needs to display the local working directory.

Using mv, the shell must know to run an external program, as this is not a shell built-in. [3].

Equally the shell is responsible for parsing the command line to detect errors in syntax. For instance typing


produces an error because there is no white space between the cd and the .. (this is a problem ex-DOS people often stumble over). In this instance the command interpreter would typically give you feedback such as

bash:cd..: command not found

Allows for variables to be set

The shell allows variables to be set. Variables such as your PATH variable, or your input field separator (IFS), or setting your shell HISTORY size.

I/O redirection

The shell is also responsible for input, output and error redirection (consult the previous chapter to refresh your memory on IO redirection).


The shell understands and allows pipes.

Customising your environment

The final job of the shell is to allow you, a user, to customise your environment. Setting variables, changing your prompt, running scripts automatically are all things that allow the user some control over their environment.


In summary, a shell script is like a batch file in DOS. Unlike the DOS command interpreter, the shell incorporates a powerful, almost full programming environment.

For instance, it allows 'if' statements, 'while' loops, 'for' loops, 'arrays', as well as a host of other programming techniques.

Scripting will make you life easier as a system administrator.

[3] a shell built-in is a command that is built into the shell and not an external command.