Main index

Introducing UNIX and Linux


UNIX and Linux Design and Organisation

Overview
The Kernel and Shell
Files
      Networks
Technical Basics
      Bits, Bytes, Words and Characters
      ASCII Characters
How to get Linux
Summary

The Kernel and Shell

In order for a computer to do any useful work, it must also perform 'housekeeping'. It needs to understand that it has various devices such as printers connected to it, and it needs to know when a user wants to run a program. These tasks, are performed by an operating system, together with many others that are required for the computer to function effectively, but are not of interest to the user. An operating system is a program, or collection of programs, that runs whenever the computer is switched on. It controls the computer, allows the user to type in instructions to the computer, and performs many other necessary functions. UNIX is an operating system.

A UNIX system can be split into two parts. While the system is operational, a program called the kernel is constantly running. This is what forms the core of the operating system and is central to UNIX. In this book, we will not be concerned with how the kernel functions, since it is not information which the user needs to know.

The other part of a UNIX system is a shell, which is the interface between a user and the system itself. It allows the user to instruct the machine and to run programs. A shell communicates with the kernel, but keeps the user at arm's length from it. It is sufficient to understand a shell; the kernel can remain hidden from the user:

Diagram of shell and kernel

The kernel is always present, but the shell is only active when someone is actually using the UNIX system. Since the shell enables the user to instruct the system to perform tasks, the instructions that can be given to the shell must be easy for a person to understand. Different individuals have had different ideas about exactly how a shell should be designed, and a number of different shells have been devised in the past. They are all similar to each other, but differ in details. The first shell, historically, is the Bourne shell, known as sh and named after its creator. This shell is still used today, although newer shells with more powerful features have been created which are effectively extensions of the Bourne shell. These include the Korn shell (ksh), the Z shell (zsh), and bash (Bourne-Again SHell). A programmer familiar with the Bourne shell should have no trouble using any of these three other shells. Indeed, if such a programmer were not using the extra features provided by these shells, he or she would be unaware that the shell was not the Bourne shell.

The C shell, known as csh, has a syntax that resembles that of the C programming language, and is markedly different from any of the shells based on the Bourne shell. A programmer familiar with the Bourne shell would not be able to use the C shell without learning the differences between it and the Bourne shell. Just as there are shells that are extensions of the Bourne shell, so the C shell itself has been developed into shells with extra facilities. The most common of these is the the tcsh (pronounced 'teesh'). POSIX.2 defines the 'standard' shell, and is modelled principally on the Bourne shell. The POSIX.2 shell contains features that have been added to the Bourne shell in the light of experience gained with other shells. Much of what is discussed in this book will thus be true for the Bourne shell. It is likely that as existing shells derived from the Bourne shell, such as ksh and zsh, are developed, each will be amended so that its specification conforms to POSIX.2.


Copyright © 2002 Mike Joy, Stephen Jarvis and Michael Luck