You are on page 1of 17

STATE UNIVERSITY OF TETOVA UNIVERSITETI

SHTETROR I TETOVS

Faculty of Mathematical Sciences - Fakulteti i Shkencave
Matematike Natyrore

Branch: Informatics

Seminar Paper

Course: Computer Networks


Topic: Operating System UNIX

Mentor:

Candidate:

Prof.Dr. Edmond Beqiri


Dushko Maxhoski ( )
Tetovo, 2014

Contents
Introduction................................................................................................................ 2
1.

History of the development of UNIX.....................................................................3

2.

UNIX OS Architecture........................................................................................... 4

3.

UNIX File System (Files and Directories)..............................................................5

4.

5.

3.1.

File System..................................................................................................... 5

3.2.

Filename........................................................................................................ 5

3.3.

Pathname....................................................................................................... 6

3.4.

File Permissions (File Users)...........................................................................6

3.5.

File Security................................................................................................... 7

UNIX Shell............................................................................................................ 8
4.1.

Bourne Shell................................................................................................... 8

4.2.

C Shell............................................................................................................ 9

4.3.

Comparison of examples in Bourne Shell and C Shell....................................9

Processes in UNIX............................................................................................... 10
5.1.

6.

Process control commands..........................................................................10

UNIX Networking / UNIX Computer Networks.....................................................11


6.1.

Standardization of network communication.................................................11

6.2.

Network Hardware....................................................................................... 12

6.2.1.
6.2.2.

LAN (Local Area Networks)....................................................................12


Bridge, repeater, router and gateway.......................................................12

6.3.

NFS (Network File System)...........................................................................13

6.4.

Basic networking commands in Unix/Linux..................................................13

References................................................................................................................ 14

Introduction
An operating system (OS) is software that manages computer
hardware resources and provides common services for computer programs.
The operating system is an essential component of the system software in a
computer system. Application programs usually require an operating system
to function.
Today there are many operating systems for platforms other than
computers from which the most used are the mobile operating systems for
Smartphones. Most popular operating systems used today are: Android, BSD,
iOS, Linux, OS X, QNX, Microsoft Windows, Windows Phone, and IBM z/OS. All
of these, except Windows, Windows Phone and z/OS, share roots in UNIX.
UNIX is a very popular operating system. It is used in labs and
universities also as in the industrial environment. There are available
versions of this system for usage in computers with general purpose, for
specialized computers, personal computers, graphics workstations and small
and large systems from different manufacturers. The main features of this
operating system are as follows:

The system is written in a high level language (C programming


language) which makes it easy to understand, modify and transfer
from one machine to another.
It has a relatively simple user interface.
The system has primitives that enable building complex processes
from base (simple processes).
It uses a hierarchical file system for easy maintenance and efficient
implementation.
Uses a consistent format for files, it sees them as an array of bytes
which makes the writing of application programs easier.
It has a simple and consistent interface for the peripheral units.
It is a multi-user, multicasting (multi process) system. Each user can
simultaneously execute multiple processes.
It supports many programming languages such as FORTRAN, Basic,
Pascal, Ada, COBOL, Lisp, Prolog, and of course the C programming
language. Also, available are more modern languages, object-oriented
language C + +, Objective C, and various CASE tools.

With the development of the X Windows environment, UNIX finally gets


a graphical user interface.

1. History of the development of UNIX


In the middle of the sixties of the 20th century was developed MULTICS
(Multiplexed Information and Computing Service) an operating system made
by AT&T Bell, General Electric Massachusetts Institute of Technology (MIT).
MULTICS posed an interactive system that was designed to serve large
customers with large requests. It proved too expensive and ambitious
because it ceased to grow.
In 1969 Ken Thompson (MULTICS system programmer of the Bell
Laboratories) and Dennis Ritchie (creator of the programming language C)
created UNICS (Uniplexed Information and computing Service) operating
system or as shortly UNIX. At first UNIX was written in assembler for later to
be translated into C programming language, which made it, became
compatible with various processor architectures.7
The developers from the Berkeley University of California modified the
translated code (most important is that they introduced networking software)
which created BSD UNIX (Berkeley Software Distribution). In 1988, a
combination of all the good features of several variants of UNIX created a
new version of UNIX - System V release 4 (SVR4), which is the basis of
modern systems.
More popular versions of BSD UNIX are 3BSD and 4BSD for VAX UNIX
systems, and 4.1BSD and 4.2BSD as well as many new versions of the
system. But that is not the end of the versions of UNIX. DEC has developed
its own UNIX (ULTRIX) for VAX and DEC's Station, Microsoft has developed
UNIX for Intel 8088 and called it XENIX, a UNIX IBM PC and for large systems.
Also there exist versions of UNIX for Amdahl, Sun, NB1, Mass Comp, HewlettPackard, Gould, Data General, Perkin-Elmer, and for many other systems.
These systems usually have a base of the following versions: Version 7,
System III, 4.2BSD and System V.
UNIX is still developing and we should expect all of its large-scale use.
As far as our environment is concerned, most often encountered are the following
versions of UNIX operating system:

SCO and Linux on computers, such as PC,


3

4.2BSD, 4.3BSD on older generation Sun workstations,


SunOS and Solaris on SPARK Sun workstations,
IRIX on Silicon Graphics, graphics workstation,
HP-UX on Hewlett Packard workstations,
ULTRIX on Digital's DEC workstations and
AIX on IBM workstations.

2. UNIX OS Architecture
An operating system can be defined as the software that controls the hardware
resources of the computer and provides an environment under which programs can
run. Generally, this software is called kernel, since it is relatively small and can be
found at the core of the environment. A diagram of the UNIX System architecture is
shown at Figure 1.1

Figure 1. Architecture of the UNIX operating system

In a broad sense, an operating system is the kernel and all the other software
that makes a computer useful and gives the computer its personality. This
other software includes system utilities, applications, shells, libraries of
common functions, and so on.

The UNIX OS Kernel controls the computer access, manages the file
systems, resources, computers, disks, tapes, printers, communication
lines and other devices.

The interface to the kernel is a software layer that is called the


system calls (the shaded part of the Figure 1.1). The Libraries of
common functions are built on top of the system call interface, but the
applications are free to use both of them.

The shell is a special application that provides an interface for running


other applications.

For example, Linux is the kernel used by the GNU operating system. Some
people refer to this as the GNU/Linux operating system, but it is more
commonly referred to as simply Linux. Although this usage may not be
correct in a strict sense, it is understandable, given the dual meaning of the
phrase operating system.

3. UNIX File System (Files and Directories)

3.1. File System


File in UNIX operating system is a collection of characters. The file size is
equal to the total number of characters that the file contains. The data within
the file does not have any structures other than those that the user defines.
The UNIX file system is a hierarchical arrangement of directories and files.
Everything starts in the directory called root whose name is the single
character /. A directory is a file that contains directory entries. Logically,
we can think of each directory entry as containing a filename along with a
structure of information describing the attributes of the file. The attributes of
a file are such things as type of file (regular file), directory, size of the file,
file owner, permissions for the file (whether other users may access this file)
and when is the last time the file was modified.
It must be noted that there is difference between the logical view of a
directory entry and the way it is actually stored on disk. Most
implementations of UNIX file systems don't store attributes in the directory
5

entries themselves, because of the difficulty of keeping them in synch when


a file has multiple hard links.

3.2. Filename
The names in a directory are called filenames. The only two
characters that cannot appear in a filename are the slash character (/) and
the null character. The slash is used to separate the filenames that form a
pathname and the null character is used to terminate a pathname. For
normal usage is good to restrict the characters in a filename to a subset of
the normal printing characters. (We restrict the characters because if we use
some of the shell's special characters in the filename, we have to use the
shell's quoting mechanism to reference the filename, and this can get
complicated.)
Two filenames are automatically created whenever a new directory is
created: . (Called dot) and.. (Called dot-dot). Dot refers to the current
directory, and dot-dot refers to the parent directory. In the root directory, dotdot is the same as dot.
The Research UNIX System and some older UNIX System V file systems
restricted a filename to 14 characters. BSD versions extended this limit to
255 characters. Today, almost all commercial UNIX file systems support at
least 255-character filenames.
In the UNIX operating system, there is no convention that links the file
names with the type of data they contain, as is the case, for example, in the
DOS operating system (all files that have the suffix .EXE are executable, .BIN
are binary etc.). However, some of the software packages require that the
files they are dealing with have certain suffixes, even though it is not caused
by the operating system. For example, the C programming language
compilers expect that the file containing the source code has extension .C.
Files whose names start with a dot (.) are treated specially by UNIX.
These are the so-called hidden files and differ from others by the fact that
their names do not appear in the standard scrolling directory contents (see
the command ls).

3.3. Pathname
A sequence of one or more filenames, separated by slashes and
optionally starting with a slash, forms a pathname. A pathname that begins
with a slash is called an absolute pathname; otherwise, it's called a relative
pathname. Relative pathnames refer to files relative to the current directory.
The name for the root of the file system (/) is a special-case absolute
pathname that has no filename component.
Every process has a working directory, sometimes called the current
working directory. This is the directory from which all relative pathnames are
interpreted. A process can change its working directory with the chdir (shell
command) function.

3.4. File Permissions (File Users)


UNIX operating system distinguishes between two types of users. One
user is known as root or super user, and he owns all rights to the system.
He has permission to do all kinds of actions such as, for example, changing
the configuration file, install new and delete pre-installed software, and even
change the kernel. Such privileges are given to a reliable and professional
person who is referred to as the system administrator. All other users
constitute a class of ordinary users and, of course, have limited rights.
All users of UNIX systems, including the super users are divided into
groups. The criteria used to divide users usually are the type of tasks for
which they are responsible. For example, a set of users working on a joint
project, they form a group. In addition, a user can belong to one or more
groups (if working on multiple projects, for example).
Viewed in size, all users of the system are divided into three classes:

Owner
Member of a group, and
Other

File owner is the user who created the file and he has the right to
determine the access permissions of the file. Of course, a super user has the
7

same right. Members of the group are the users who belong to a group
that includes the owner of the file. All other users are treated as others.
For each class of file users, it is possible to define individual access
permissions. For example, it is common that the owner has all the rights of a
file (read, write and execution, if it is executable), group members are
granted the right to read (without changing content), while other users do
not have any right of access to the file.
File access control is relatively simple and can be done with the following
shell commands: chown, chgrp and chmod.

3.5. File Security


File security has been undertaken for the following reasons:

To prevent from unauthorized access, using or deletion of data stored


in file.
To prevent or unintentional deletion of files by accident , change the
contents of a file or harm the file in any kind.
Enable multiple users to use data from the same file, but still each of
them will have different rights over it. A typical case is when only one
user can change the content and more of them can read the data from
a file.
Ensure (protect) the contents of the file in case of malfunction or
failure of the system.

File protection in the UNIX operating system is based on a controlled


access to the data the file contains. The rights that a user may have on a file
are named access permissions. For each file in the UNIX operating system,
it is possible to control the following types of access permissions:

Read (users are allowed to read the file)


Write (users are allowed to write in the file or delete it)
Execute (users are allowed to execute the file)

4. UNIX Shell
A UNIX shell is a command-line interpreter or shell that provides a
traditional user interface for the UNIX operating system and for Unix-like
systems. Users direct the operation of the computer by entering commands
8

as text for a command line interpreter to execute, or by creating text scripts


of one or more such commands. Users typically interact with a UNIX shell
using a terminal emulator, however, direct operation via serial hardware
connections, or networking session, are common for server systems.
In most version of the UNIX OS, usually are available the following shell interpreters.
Shell
Bourne
Shell
C Shell

Description
/bin/sh - Easy to use, flexible, with built-in programming language.
/bin/rsh - reduced version of the Bourne Shell.
/bin/csh - a command interpreter and a programming language that
supports command buffer, control operations, and C-like syntax.
/bin/ksh - additional features compared to the Bourne Shell.
/bin/rksh - reduced version of the Korn shell.
/bin/tcsh - improved version of the C shell. It has a better command
line editing, file names completion, command repetition.

Korn
Shell
Turbo C
Shell
The most influential UNIX shells have been the Bourne shell and the
C shell. These shells have both been used as the coding base and model for
many derivative and work-alike shells with extended feature sets.

4.1. Bourne Shell


The Bourne shell was one of the major shells used in early versions of
the UNIX operating system and became a de facto standard. It was written
by Stephen R. Bourne at Bell Labs and was first distributed with Version 7
Unix, circa 1977. Every Unix-like system has at least one shell compatible
with the Bourne shell. The Bourne shell program name is sh and its path in
the UNIX file system hierarchy is typically /bin/sh. On many systems,
however, this may be a symbolic link or hard link to a compatible, but more
feature-rich shell than the Bourne shell.
Bourne shell example: This command takes filenames as its parameters. If
a file exists it changes the modification date. If no file exists it creates a new
one.
#!/bin/sh
flag=
for i
do
case $i in
-c)
flag=N ;;
*)
if test -f $i
then
ln $i junk$$
rm junk$$
elif test $flag
# true if not null
then
echo \'$i\' does not exist
else
>$i
fi ;;
esac
done

4.2. C Shell
The C shell was developed by Bill Joy for the Berkeley Software Distribution, a
line of UNIX operating systems derived from UNIX and developed at the University
of California, Berkeley. It was originally derived from the 6th Edition Unix shell
(Thompson shell), with its syntax modeled after the C programming language. The C
shell is used primarily for interactive terminal use, and less frequently for scripting
and operating system control. It has interactive keyboard shortcuts in form of
special control-key sequences for special effects such as job control.
Simple example of C shell: Simple example that shows a message This is
over a year If 365 days have passed.
#!/bin/csh
if ( $days > 365 ) then
echo This is over a year.
endif

4.3. Comparison of examples in Bourne Shell and C Shell


Here is an example, comparing scripts that calculate the first 10
powers of the number 2.
Bourne Shell
#!/bin/sh
i=2
j=1
while [ $j
echo '2
i=`expr
j=`expr
done

-le 10 ]; do
**' $j = $i
$i '*' 2`
$j + 1`

C Shell
#!/bin/csh
set i = 2
set j = 1
while ( $j <= 10 )
echo '2 **' $j = $i
@ i *= 2
@ j++
end

5. Processes in UNIX
Process is found as a special term in the UNIX operating system. The process
is the basic unit of UNIX that is executed. Commands and tasks can be
10

executed in a process, but may require more processing.


There are several types of processes:

Interactive processes-processes that require controlled via the


terminal. Can be run in foreground or background mode.

Batch processes-processes that are running in batch processing, i.e.


defined by the sequence of processes that are executed sequentially.

Daemons-server processes running in the background-and wait until


some other process does not require their services.

Each process has the following attributes:

Process ID - Unique identification number for the process

Nice number - number that defines the priority of the process for capturing
computer resources

TTY-mark terminals from which the process was started

5.1. Process control commands.


System shutdown command for BSD UNIX:
/etc/shutdown [-h | -r] [sec] - Stops all processes, shuts system down or
restarts it. Can be executed only by a system administrator (On the system
Logged in as root)

h stops all processes and stops the system. Only after this command,
the system can be shut down from the hardware side (power of).
r - stops all processes and restarts the system.

sec time after which the command is executed.

Examples:

Shutdown
# /etc/shutdown - h 0

Restart
#

6. UNIX
Networking
/etc/shutdown
-r /0 UNIX Computer Networks
...

...
11

6.1. Standardization of network communication


The development of computer networks began roughly when the development
of UNIX operating system also started the early seventies. The goal of the
networking of communication equipment is to form a virtual working environment
within which devices from different manufacturers can share their resources
(processing power, expensive peripherals such as printers, plotters, disk drives,
etc.).
In order that computer equipment of different manufacturers can be connected
in a single network environment, it was necessary to standardize the procedure that
is the protocol by which the communication is to take place. In the year 1977 ISO
started work on the standards of this kind and as a result of those activities
originated hundreds of protocols that should be accepted internationally. The set of
those protocols constitute the OSI (Open System Interconnection) reference
model. At the same time, DOD (Department of Defense) in the United States
developed another set of standards, known as the TCP / IP model, and based on
their own computer networks. Later, in a slightly altered form, this model is
accepted as IEEE standard. Otherwise, the acronym TCP and IP originate from the
Transport Control Protocol and Internet Protocol, respectively. The TCP / IP
model differs from the OSI model. In a rough approximation, we can say that these
two models correspond up to the transport layer. Standardization above this level in
the TCP / IP model is left to the teams that develop network applications, while that
is not the case with the OSI model. The literature often faces the dilemma of
whether the TCP / IP is made by the OSI model or not? It can be said that some
applications that rely on TCP / IP are subject of the OSI model. One such application
is the NFS (Network File System), which is essentially a standard for organizing
network drives. The structure of NFS was created by dividing the application-level
TCP / IP models in three layers that fit perfectly into multiple layers of the OSI
model.

12

Figure 2. The three Network Reference Models

6.2. Network Hardware


6.2.1.LAN (Local Area Networks)

Local Area Networks have a very simple structure and use a number of
different hardware equipment. First of all, these networks are characterized
by the fact that they connect computers in small regions. These are for
example networks within a building. In our environment most often are used
networks using Ethernet as the physical layer protocol. These are the socalled BUS network topology, and used transmission medium is a coaxial
cable with impedance of 50 ohm and a data transfer rate of 10MB / s. In
order for the network to work properly the coaxial cable must be terminated
at both ends with terminators whose resistance is equal to the corresponding
impedance of the cable. Connections for PCs are derived by breaking the
cable and inserting a T connector.

13

Figure 3. Ethernet Network with coaxial cable and T connectors .

6.2.2.

Bridge, repeater, router and gateway

Due to the electrical specifications, the maximum segment length of coaxial


cable in the network is limited to 160m. If the length of cable required for the
formation of the network exceeds the maximum allowed value, such a network is
divided into two or more segments whose length is less than the maximum, with a
mutually connecting bridge's or repeater's . So bridge and repeater represents a
communication equipment that connects two segments of the same network, in
relation to the repeater, bridge is the intelligent device with the ability to filter
traffic.
Similarly, two different networks to connect into a single unit using a router. In
the case that networks are based on different protocols (such as TCP / IP and X.25)
the device that is connecting them is called gateway.

6.3. NFS (Network File System)


NFS (Network File System) is a network service that allows the creation and
use of network drives. Its use is very simple, because the service is completely
transparent to the user and the network drive behaves exactly the same as the
parts of the local file system.

Figure 4.
Example of NFS
structure of two
hosts.

NFS is mainly used because of the following reasons:

To increase the size of the file system. In this case, host B cannot
use the network part of the drive to save files without burdening local
drives.
File sharing. The network part of the disc at the same time sees two or
more hosts and thus can interchange data without file transfer. For
14

example, the file that is copied to the local disk on a network host B
becomes simultaneously available to users on host A.

6.4. Basic networking commands in Unix/Linux


There are a lot of commands that can be used on UNIX servers that can control and
show the user information about the networks. Here are some of the most basic
ones:

finding host/domain name and IP address - hostname


test network connection ping
getting network configuration ifconfig
Network connections, routing tables, interface statistics netstat
query DNS lookup name nslookup
communicate with other hostname telnet
outing steps that packets take to get to network host traceroute
view user information finger
checking status of destination host - telnet

15

References
(1) W. Richard Stevens, Stephen A. Rago - Advanced Programming in
the UNIX Environment: Second Edition - Addison Wesley Professional,
2005
(2) R. Morgan, H. McGilton - "Introducing UNIX System V" - McGraw-Hill,
1987.
(3) P. P. Sylvester - "UNIX vodic kroz sistem" - Mikro Knjiga, prevod, 1992.
(4) http://www.wikipedia.com

16

You might also like