Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 11

UNIT – IV

UNIX OPERATING SYSTEM


Features of UNIX
Multiuser
Most operating systems are designed to support single user systems. When several
users want to share the system resources we need a multiuser system.
UNIX is an operating system which supports multiuser systems. All users have
terminals connected to a system and they can use the system at the same time. That is each user
is allotted a time slice without his knowledge. So each user has an impression that he has his
own computer. All the system resources are allotted automatically by the system without the
knowledge of the user. So UNIX operating system is a multiuser system.

Multi-process
Multi process means the capacity of the operating system to perform several
tasks(works) simultaneously.
UNIX is a multi process operating system which allows a user to run more than one job
at a time. This feature is called multitasking. This feature allows the user to perform less urgent
jobs in background, while performing important one’s in the foreground. So it is possible to print
one document, edit another and sort a list of files at the same time.

Time sharing
Time sharing systems are systems in which the processes share the CPU in a time
shared manner.
UNIX is a time-sharing system which allows several users to run programs on different
terminals at the same time. The operating system allocates the CPU to a process for a period of
time called time-slice. When the time-slice expires the CPU transfers the process and schedules
another to the CPU.

Portable
One of the important features of UNIX operating system is, it can be used with any
type of computer hardware without any major changes. This ability to adapt to different
computers is called portable.

44
Shell and Kernal – Structure of Unix
The entire UNIX system can be divided into two sub structure. They are
(i) Kernal
(ii) Shell
Kernal
It is the core (central part) of the operating system. It controls all the tasks. The kernel
contains thousands of small programs related to different tasks handled by the operating system.
These are written in C language. The functions of kernel are
(i) It keeps track of the program in execution
(ii) It allots processor time to each program
(iii) It decides when one program stops and an other starts
(iv) It handles information exchange between system and the I/O devices
In other words, the kernel is what we call an operating system. It is the heart of UNIX system.

Shell
It is the command interpreter of the operating system. The functions are
(i) It accepts commands from the user and interprets it.
(ii) It starts executing the appropriate executable file.
(iii) It requests the kernel to carry out I/O transfer.
Thus the shell acts as middle man between the kernel and the user. There are three mainly used
shells with UNIX. They are
(i) The Bourne shell (ii) The C shell (iii) The Korn shell

The Bourne shell


It is the primary UNIX command interpreter. It comes along with every UNIX system.
The dollar ($) prompt on UNIX installations is the trademark of the Bourne shell.

The C Shell
The C shell remembers the commands that the user types and allows the user to recall
them without having to retyping them. This is very useful because UNIX commands are very
long.

45
The Korn Shell
The korn shell includes all the developments in the C shell like common history and a
few more other features.

User Shell for Shell for


X User X User Z
User
Z

kernal

Compute
r
Hardwar
e

User Shell for


Y User Y
Means two way information transfer

SECURITY
In UNIX system several levels of security exist. They are
(i) Login
A standard login procedure is followed before starting the UNIX system. This is achieved by
giving a password to each user.
(ii) Permission
Each user of the system can assign permissions like read, write and execute to their files.
(iii) Encryption
Users of the system can encrypt their data files so that others cannot use it.

46
COMMUNICATIONS
UNIX system supports two types of communications. They are
(i) Communication between different terminals connected to the same computer.
(ii) Communication between users of different computers placed at different
locations.
Program Development Tools
UNIX system has number of program development tools. These vary from one
implementation of UNIX to another. These tools help to perform the day-to-day as well as
complex tasks of the system.
Program in the outer layers interact with the kernal through the program development
tools. These tools instruct the kernal to do various operations for the calling program and
exchange data between the kernal and the program. The figure given below shows the tools.

Application Program

nroff sh who

cpp a.out

date
comp

we Program
as Development
Tools
grep
ld
vi ed

The following are the example of tools.


as  assembler
ed  text editing
date  status information
grep  text processing

47
FILE SYSTEM

The File
In UNIX everything is treated as a file. So these things are divided into three important
types. They are
(i) Ordinary file or regular files
(ii) Directory files
(iii) Device files

(i) ORDINARY FILE

This file is the most frequently used file. Most of the files that a user create and edit
applications are ordinary files. There are four types of ordinary files. they are

(a) Text file


This file contains ASCII characters. ASCII characters are numerical representation of
regular letters and numbers.

(b) Data file


This file is a part of text file. This contains additional instructions on how the characters
are to be treated by the application.

(c) Command text files


These files are ASCII files used to provide command to our shell.

(d) Executable files


This file contains programs in binary code created by the programmer.

(ii) DIRECTORY FILES


A directory is a place where files and sub directories reside. This contains no data, but a
list of files and subdirectories.
Directory file contains a list of files and sub-directory. Each entry in this file consists of
two parts. They are
(i) The name of the file
(ii) The pointer to the file attributes on the disk

(iii) DEVICE FILES

Each and every physical device such as printers, tapes, floppy disks etc are considered as
files in UNIX system. Device file represents the physical devices of the computer system. No
special commands or functions are required to use these files.

48
The user cannot read or change these files. These files are used by the operating system
to communicate with the physical devices. So any output directed to the physical devices will be
reflected into the respective device files. Thus when we given a command to print a file, we are
directing the output to the file associated with the printer.

STRUCTURE OF FILE SYSTEM

UNIX file system is a collection of the following files. they are,


(i) Ordinary files
(ii) Directory files
(iii) Device files
So the UNIX file system is structured like a tree and is shown below.

The top most hierarchy is called root and is the master directory of the entire system.
This is usually called as root directory. Root directory is a directory file and it contains other
directories (sub-directories) as members. Directories are designated by a / (front slash). These
sub-directories in turn contain number of sub-directories and other files.

/usr, /bin, /etc, /dev, /bin, /tmp are sub-directories of the directory /root. Here the
directories /bin, /dev, /lib and /etc are system directories. The other directories /tmp and /usr are
meant for the users.

HOME DIRECTORY OR LOGIN DIRECTORY

Each user of the UNIX system associates with a particular directory. When a user log
into the system, he is placed automatically into a directory called his HOME directory. This
directory is assigned to each user by the system administrator.

49
Checking the current directory
pwd command is used to display the current working directory. The general form is
pwd
pwd – print working directory.
When we enter into the system we are placed in the home directory. To verify this, pwd
command is used. This command prints the complete path name of the current working
directory.

Changing directories
cd command is used to change the working directory to some other working directory.
The general form is
cd name
where
cd – command
name – name of the new working directory.

Example:-
(i) Suppose a user is working in a sub-directory /usr/bin. If the user wants to change
his directory to /abc, the command is
$pwd
/usr/bin
$
This is the current directory.
$cd/abc
$pwd
/abc
$
Here the directory is changed from /usr/bin to /abc.

(ii) The cd command can be used without arguments.


$pwd
/usr/bin
$cd
$pwd
/usr
$
cd command without arguments takes the user to the parent directory of the current
working directory.

50
Listing out Directory contents
ls command is used to list out the directory contents.
The general form is ls [-options] name
Where ls is command.
Options a – to list all directory entries
d – to list name of directories
l - to list files in long form
r – to list files in reverse order
t – to list the files sorted by time
F – to mark executable files with * and directories with /
S – to list number of blocks used by a file
1 – one file per line
name – name of a file or directory to be listed
Example:-
1. $ ls-1/etc - list the long form of the directory /etc
2. $ ls-1/etc/abc - list the long form of the file abc in the directory /etc.
3. $ ls – 1 - This displays the content of the current working directory in long form
as
total 10
-rw-rw-rw-2 abc Group 512 May 06 14:40 emp
The number 10 indicates the total number of blocks used by the file.
First column –rw-rw-rw gives he type of permission given to the file.
Second column 2 gives the number of links associated with the file.
Third column abc gives the owner of the file.
Fourth column Group gives the group to which the owner belongs to
Fifth column 512 gives the size of the file in bytes
Sixth column gives the last modification date
Seventh column gives the last modification time
Eighth column emp gives the file name.
Create file
cat command is used to create a file. The general form is: cat> filename
where cat – command, > - direct the data from keyboard to file, filename – name of the file to be
created.

51
Example:- Create a file named CARE and place the names SNAJU, SHALU and JACK as its
contents.
$ cat > CARE
SHANU
SHALU
JACK
$
To come out of this command press ^d.
This creates a file CARE in the current working directory. The characters in each line of the file
should not exceed 14 characters.

Display a file
cat command is used to display the content of the file. The general form is,
cat name.
Where,
cat - command
name - name of the file to be displayed.
Example:
$ cat CARE
This command displays the content of the file CARE as,
SHANJU
SHALU
JACK

Making and Removing Directories

Making a Directory:
mkdir command is used to create a directory in the current working directory. The
general form is,
mkdir directory-name
Where,
mkdir – command
directory-name – name of the directory to be created.
52
Examples:-
$ mkdir ahmed
This command creates a new directory named ahmed in the current working directory.

Removing a directory:
rmdir command is used to remove a directory from current working directory. The
general form is,
rmdir directory-name
Where,
rmdir - command
directory-name – name of the directory to be removed
Example:-
$ rmdir ahmed
This command removes ahmed directory from the current working directory.

File Permissions
File permission means giving permission to users to access files. There are three modes
for accessing a file. They are
i) Read mode
ii) Write mode
iii) Execute mode
An user can use the above modes for a file only if he is having the corresponding
permission.

UNIX system divides the user into three groups. They are
(i) User
(ii) User Group
(iii) Others
The person who is responsible for the UNIX system assigns file permissions to the above users.
The general form of the file permission is
-rwxrwxrwx[OR]drwxrwxrwx

53
* The first character gives the type of the file. If it is – then it is an ordinary file. If it is d then it
is a directory file.
* The second three characters rwx gives the read(r), write(w), execute (x) permission to the
person who created the file. That is the user.
* The third three characters rwx gives read, write, execute permission to the group which owns
the file. That is the group to which the owner belongs(user group)
* The fourth three characters rwx gives the read, write, execute

Path names:
Path names enable us to identify a particular file or a directory in the UNIX system.
While specifying path name the directories along the path are given and separated by / character.
A path name that begins with / character is called full path name.
Consider the directory system as given below,

To identify the directory c1 in the a1 file system, we have to give, /a1/ahmed/c1


To identify a file c11 in the a1 file system we have to give, /a1/ahmed/c1/c11.

54

You might also like