UNIX Introduction

This session concerns UNIX, which is a common operating system. By operating system, we mean the suite of programs which make the computer work. UNIX is the foundation underlying MacOS X and Linux computers, among others.

UNIX-based systems like Linux and MacOS X normally provide a graphical interface between the user and UNIX. However, knowledge of UNIX is required for operations which aren't covered by a graphical program, or for when there is no graphical system available (e.g. when you login remotely to a computer via SSH).

The UNIX operating system

The UNIX operating system is made up of three parts: the kernel, the shell and the programs.

The kernel

The kernel of UNIX is the hub of the operating system: it allocates time and memory to programs and handles the filestore and communications in response to system calls.

As an illustration of the way that the shell and the kernel work together, suppose a user types rm myfile (which has the effect of removing the file myfile). The shell searches the filestore for the file containing the program rm, and then requests the kernel, through system calls, to execute the program rm on myfile. When the process rm myfile has finished running, the shell then returns the UNIX prompt % to the user, indicating that it is waiting for further commands.

The shell

The shell acts as an interface between the user and the kernel. When a user logs in, the login program checks the username and password, and then starts another program called the shell. The shell is a command line interpreter (CLI). It interprets the commands the user types in and arranges for them to be carried out. The commands are themselves programs: when they terminate, the shell gives the user another prompt (% on some systems, $ on others--there's a wide variety of prompt styles).

The adept user can customise his/her own shell, and users can use different shells on the same machine.

The shell has certain features to help the user inputting commands:

Files and processes

Everything in UNIX is either a file or a process.

A process is an executing program identified by a unique PID (process identifier).

A file is a collection of data. Files are created by users using text editors, running compilers, taking photos with a digital camera, etc.

Examples of files:

The Directory Structure

All the files are grouped together in the directory structure. The file-system is arranged in a hierarchical structure, like an inverted tree. The top of the hierarchy is traditionally called the root.

The Unix file structure

In the diagram above, we see that the directory ee51ab contains the subdirectory unixstuff and a file proj.txt

Starting a Terminal session

To start a Terminal session, double-click on the "Macintosh HD" icon on your desktop and navigate to Applications/Utilites/Terminal. You can then double-click on Terminal to launch it. If you want to make things more convenient, you can drag the Terminal icon to your Macintosh dock (the row of icons representing commonly-used programs that appears on your screen all the time). That way you won't have to navigate to Terminal every time you want to use it.

Once you have launched Terminal, it will look something like this.

A Terminal window

 

M.Stonebank@surrey.ac.uk, © 9th October 2000