Introduction to Unix.
The Unix operating system was developed at Bell Labs by researchers who withdrew from the development of the Multics operating system because it was too large and complicated. Unix was chosen as the name for the new operating system because it was an emasculated Multics.
The decision to write Unix in the C programming language was controversial because programmers at the time thought that the execuation speed penalty of a high level language would make it run too slowly. However, writing it in C made it much easier to port to different computers. The ease with which it can be ported and modified has made its descendants the dominate operating systems of the early twenty first century. Unix's decendants include OSX, iOS, Linux, and Android, Unix's challengers in the 1970's were IBM operating systems, whose only wide-spread descendant is Windows.
Operating systems encapsulate computer hardward in software to make the hardware easier to use. It provides a common interface to the hardward and makes the hardware easier to use.
Unix divides the operating system into the kernel and the system's software. The kernel encapsulates the hardware, providing an common interface. It has priviledged access to the hardware: any other program that needs to access the hardware must do so through the operating system. By restricting other programs from using the hardware directly, the Unix kernel can ensure common access from all other applications.
System software runs in user space. Unlike the kernel, it does not have priviledged access to the hardware. Indeed, the primary difference between systems software and other programs is that it comes packaged with the Unix operating systems. Most of the Unix commands you will use are actually system software running in user space.
Figure 1 shows a diagram of the Unix operating system. The hardware is drawn at the center of the diagram surrounded by the kernel. The kernel is, in turn, surrounded by the system software which contains many of the common Unix commands.
Though most Unixes have applications with a Graphical User Interface (GUI) the most common way to interact with Unix is through a terminal. Windows also has a terminal interface called
The shell is an important Unix system program. The shell accepts commands typed into the terminal and executes them. It executes two types of commands: internal and external. Internal commands are built into the shell. External commands are other programs in user space that the shell initiates in their own process. Generally internal commands execute faster than external commands, but the difference is small on modern computers.
Unix commands follow this format:
command option(s) filename(s)Unix used white space (tab, space) to separate fields and line feeds to separate records. A command is a single record, which the shell interprets as a request for an action. Each option is specified by a letter or string of letters possibly followed by another string of letters. Each filename is interpreted as an operand to the command.
For example, the cat
will display the content
of a file on the screen. For example, if we have a file
called RomeoAndJuliet that
contains the Shakespeare's Romeo and Julliet. We can print
it out on the screen using the command:
cat RomeoAndJulietOur terminal will show us:
cat -n RomeoAndJuliet
Most Unix commands have more options that anyone can
remember. Fortunately, there is a command man
that shows all of the options. To find out all of the
options for cat, type
man catAnd, fortunately, the results of typing
man
do
no scroll off the screen. Instead, a single page is
displayed. At the bottom of the screen man
displays a colon. If you type a space, the next page is
displayed; if you type a carriage return (enter or return)
the next line is displayed. If you type 'b', the previous
page is displayed. If you type 'q' the the man
command terminates.
The options start with a '-', to distinguish them from the
filenames. If you supply cat with multiple filenames, the
content of all of the files display on the screen. For
example, Lets create two files: one,
called file1
containing "This is the first
file." and the second, called file2
containing
"This is the second file." When you type cat file1
file2
you will see the following:
The string file1
names a file. This name refers
to the sequence of character "This is the first file.",
stored in the computer. All files have names, and they
reside in directories. Directories contain files
and other directories. Directories may not contain themselves of
directories than contain themselves, so they form a
structure like a family tree. The root of the
directory structures is the ultimate ancestor of all of the
other directoreis. The root's name is "/".
The command ls
shows the contents of a
directory, like the command cat
shows the
contents of a file. For example, to see the contents of the
root type
ls /Some of the directories ls will list are: bin, boot, dev, etc, and home. The bin directory contains the programs that make up the ring around the Unix kernel. For example, you will find
ls
in
the /bin
directory. This file contains the
instructions to make the computer list the contents of a
directory.
Notice that the directory containing the Unix system
programs in specifiec as /bin
. This designation
is called an absolute directory name because it specifies
the route it starts at the common ancestor of all files, the
root. Because directories form a structure like a family
tree, starting at the root always specifies a unique
file. In computer science, the structure in which nodes are
attached only to parent nodes, all of which trace back to
the root, are called trees. The Unix directory
structure forms a tree.