Professional Documents
Culture Documents
History of Unix :
The Unix operating system found its beginnings in MULTICS, which stands for
Multiplexed Operating and Computing System. The MULTICS project began in the mid
1960s as a joint effort by General Electric, Massachusetts Institute for Technology and
Bell Laboratories. In 1969 Bell Laboratories pulled out of the project.
One of Bell Laboratories people involved in the project was Ken Thompson. He liked the
potential MULTICS had, but felt it was too complex and that the same thing could be
done in simpler way. In 1969 he wrote the first version of Unix, called UNICS. UNICS
stood for Uniplexed Operating and Computing System. Although the operating system
has changed, the name stuck and was eventually shortened to Unix.
Ken Thompson teamed up with Dennis Ritchie, who wrote the first C compiler. In 1973
they rewrote the Unix kernel in C. The following year a version of Unix known as the
Fifth Edition was first licensed to universities. The Seventh Edition, released in 1978,
served as a dividing point for two divergent lines of Unix development. These two
branches are known as SVR4 (System V) and BSD.
Ken Thompson spent a year's sabbatical with the University of California at Berkeley.
While there he and two graduate students, Bill Joy and Chuck Haley, wrote the first
Berkely version of Unix, which was distributed to students. This resulted in the source
code being worked on and developed by many different people. The Berkeley version of
Unix is known as BSD, Berkeley Software Distribution. From BSD came the vi editor, C
shell, virtual memory, Send mail, and support for TCP/IP.
For several years SVR4 was the more conservative, commercial, and well supported.
Today SVR4 and BSD look very much alike. Probably the biggest cosmetic difference
between them is the way the ps command functions.
UNIX has a rich variety of editors available ranging from the minimal to the truly exotic.
The vi Editor
In 1976, Bill Joy took the sources of the two line editors ed and ex, and created vi. Vi
soon attracted a large following and has since evolved into many different versions for
many platforms. Vi is the default Unix editor.
Pico is an extremely simple and easy to use editor. It was written in 1989 for the email
client Pine by the administrative staff of the University of Washington.
The first Emacs was born in 1975 at MIT as a set of macros written for the editor TECO
under ITS on a PDP-10 machine. It was written by Richard Matthew Stallman (RMS).
RMS went on to write the now widely popular GNU Emacs as part of the GNU project.
Architecture of Unix Operating System :
• Hardware :
This contains all the various hardware devices connected to the system.
• Kernel :
o The core of the UNIX system. Loaded at system start up (boot). Memory-
resident control program.
o Manages the entire resources of the system, presenting them to you and
every other user as a coherent system. Provides service to user
applications such as device management, process scheduling, etc.
o Example functions performed by the kernel are:
managing the machine's memory and allocating it to each process.
scheduling the work done by the CPU so that the work of each user
is carried out as efficiently as is possible.
accomplishing the transfer of data from one part of the machine to
another
interpreting and executing instructions from the shell
enforcing file access permissions
o You do not need to know anything about the kernel in order to use a
UNIX system. These details are provided for your information only.
• Shell :
o Whenever you login to a Unix system you are placed in a shell program.
The shell's prompt is usually visible at the cursor's position on your screen.
To get your work done, you enter commands at this prompt.
o The shell is a command interpreter; it takes each command and passes it to
the operating system kernel to be acted upon. It then displays the results of
this operation on your screen.
o Several shells are usually available on any UNIX system, each with its
own strengths and weaknesses.
o Different users may use different shells. Initially, your system
administrator will supply a default shell, which can be overridden or
changed. The most commonly available shells are:
Bourne shell (sh)
C shell (csh)
Korn shell (ksh)
TC Shell (tcsh)
Bourne Again Shell (bash)
o Each shell also includes its own programming language. Command files,
called "shell scripts" are used to accomplish a series of tasks.
• Utilities :
o UNIX provides several hundred utility programs, often referred to as
commands.
o Accomplish universal functions
editing
file maintenance
printing
sorting
programming support
online info
o Modular: single functions can be grouped to perform more complex tasks .
UNIX File System and Commands
The standard system directories are shown below. Each one contains specific types of
file. The details may vary between different UNIX systems, but these directories should
be common to all. Select one for more information on it
/(root)
|
--------------------------------------------------------------
| | | | | | | |
/bin /dev /etc /home /lib /tmp /usr kernel file
Absolute pathnames:
Every file and directory in the file system can be identified by a complete list of the
names of the directories that are on the route from the root directory to that file or
directory.
Each directory name on the route is separated by a / (forward slash). For example:
/usr/local/bin/ue
You can define a file or directory by its location in relation to your current directory. The
pathname is given as / (slash) separated list of the directories on the route to the file (or
directory) from your current directory.
A .. (dot dot) is used to represent the directory immediately above the current directory.
Unix Commands :
1. cd - to change directory.
cd<name>
B) Display:
1. cat - to display a file on the screen.
cat <filename>
2. head - to display first few lines (usually 10) of a file.
-lines specifies the number of lines to display.
head<[-lines] <filename>
C) Editing :
3. cmp - to compare two files and tell the line numbers where they differ.
cmp <onefile> <anotherfile>
Example:
example – kill -s kill 100 -165 ----- Kills job 1 of uid 165
example - cal - Would give you the calendar for this month.
cal 12 2000 - Would give you the calendar for December of 2000.
date -s "11/20/2003 12:48:00" - Set the date to the date and time shown.
DATE:02/08/01
TIME:16:44:55
When using mounting, the mount command must know what is the device or partition to
be mounted and what is the mount point. The mount point must be a already existing
directory on the system.
Example: $ mount /dev/fd0 /mnt/floppy
Here /dev/fd0 is floppy drive and /mnt/floppy is the mount point..
or $ umount /dev/fd0
here /dev/fd0 is the device to umount
Example:
The command will print details of your files on the screen.
$ ls -l > bigfile
Will create bigfile which contains output of ls –l command.
Example
$ cat file3 >> bigfile
Will add the contents of file3 to the end of bigfile. The old contents of bigfile are not
deleted by this.
3. Redirected Input
Redirected input is run by typing a command like this
command < inputfile
The program reads its input data from the file instead of the keyboard.
Features of Unix :
• It is multitasking, therefore, multiple programs can run at
one time.
• It is multiuser, allowing more than a single user to work at
any given time. This is accomplished by sharing processing
time between each user and utilizing distributed computing
systems.
• It is safe, preventing one program from accessing memory
or storage space allocated to another, and enables
protection, requiring users to have permission to perform
certain functions, i.e. accessing a directory, file, or disk
drive.
Vi Editor :
What is vi?
The fundamental UNIX editor is called vi. It is a primitive editor, but it will be found on
every UNIX system, and works well when logging in remotely from home. There are just
a few commands that one needs to learn at first, and they will be sufficient to write
simple files. For more advanced features, consult some of the handouts and books
available in the CS lab.
The Basics of vi :
There are essentially three Modes in vi, the Insert Mode where one is typing in new text,
the Edit Mode where one is modifying text that is already there, and the Command
Mode where one is interacting with the operating system with actions like reading and
writing files.
Most of the commands require just a simple letter or two, but be careful to note that vi is
case sensitive, and capital letters do different things from lower case letters. It is not
necessary to learn all of these commands, but eventually they will become second nature.
The basic operations needed to create a file are related to each of those modes, so let's
look at them separately.
Letter Action
Modifying Text
Replaces the character under the cursor with the next thing
r
typed
J Joins current line with the one below (Capital J!)
p Puts the yanked text on the line below the cursor (lower case p)
Note: If vi is already in the input mode, text from that or another window may be
highlited using the left mouse button, and copied into place by pressing the
middle mouse button.
• COMMAND Mode - For interacting with the operating system.
To enter the Command Mode, a colon " : " must precede the actual command.
Letter Action