A Quick Introduction to Unix/Components
Unix is made up of three components
- the kernel;
- the shell; and
- programs.
The kernel
editThe kernel of Unix is the heart of the operating system. It allocates time and memory to programs and handles the file structure and communication between the different parts of the computer system such as the keyboard and the screen.
The shell
editThe shell is an interface between the user and the Unix kernel. It resembles the ‘dos box’ that Windows displays if you run the command cmd. When a user logs in, Unix checks their username and password and then starts a program called the shell. The shell interprets the commands the user types and transmits them to the kernel to be executed. These commands are programs.
There are a variety of shells available for the various Unix systems. The expert user can customise their own shell and users can use different shells on the same machine.
The shell and kernel work together like this:
- a user types cat somefile to display a file;
- the shell finds the program cat;
- the shell instructs the kernel to run the program cat on somefile;
- When the program finishes the kernel passes control back to the shell and displays the Unix prompt.
Which shell?
editThere are a number of different shells for Unix. People can become very attached to the shell they prefer. Popular shells include
- sh - the bourne shell
- bash - the bourne again shell
- csh - the c shell
- ksh - the Korn shell (strangely, not named for the band)
- zsh - the z shell
You can invoke any shell installed on your system with one of the above commands at the prompt. (Notice that this means you start a new shell within a shell!). We won't cover the distinctions about different shells at this time. When you begin to write Unix Shell Scripts you will probably want to choose a shell and stick with it if you can. Each shell has its advocates. The Bourne again shell is popular with many script writers. Some in the Unix community have expressed doubts about the suitability of the c shell for scripting, but this is something you can address when you know more about Unix (see Csh Programming Considered Harmful).
You can start a shell of a particular kind by typing the shell name at the command line prompt.
Programs
editPrograms are not part of the operating system as such, but they are logical sequences of commands, developed for implementing specific tasks. They usually include application software running at the user end.