Chapter 2. The Shell

Table of Contents

What is the login shell?
The job of the shell
Command Interpreter
Allows for variables to be set
I/O redirection
Customising your environment


In order to work with the shell, you will need to be logged in as your user on your system.

What is the shell? The shell is a command interpreter, which I'll talk about in a minute. In essence, there are two types of shells:

  1. the login shell and

  2. the non-login shell

The login shell's responsibility is to log you into the system. This is the shell you get when you're prompted with your username and you have to enter your password. The second type of shell is a non-login shell. This is the shell we're going to be programming in, which in my case, is bash, but could also be the sh, csh , the ksh, or another shell.

There are many non-login shells. We're not going to be concentrating on all the non-login shell as there are most probably 50 different shells that one could use. In order to understand the shell, we need to understand a little more about how the shell starts up.

I'm going to explain the start-up process briefly in order to convey an idea of where your login settings are. For a full comprehensive description of these files, consult the system administration course in this series.

Throughout this course, we'll use bash, primarily because that's the shell that you're probably going to have as your non-login shell on most Linux systems. How do you find out what shell you're using? Well the easiest way to do this, is:

echo $0

$0 will return "bash" if you're using the Bourne Again shell, or "sh" if you're using the Bourne shell, "ksh" if you're using the korn shell or "csh" if you're using the C shell or the tcsh.

Once you've established what shell you're using, you know what command interpreter set you're going to be using when creating shell scripts.