0% found this document useful (0 votes)
7 views

Introduction To Unix1

Uploaded by

Himani Verma
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Introduction To Unix1

Uploaded by

Himani Verma
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 65

Introduction to OS &

Unix
Dr. Sarvesh Tanwar
What is an Operating System?
• A program that acts as an intermediary between a user of a computer
and the computer hardware
• Operating system goals:
• Execute user programs and make solving user problems easier
• Make the computer system convenient to use
• Use the computer hardware in an efficient manner
Computer System Structure
• Computer system can be divided into four components:
• Hardware – provides basic computing resources
• CPU, memory, I/O devices
• Operating system
• Controls and coordinates use of hardware among various applications and users
• Application programs – define the ways in which the system resources
are used to solve the computing problems of the users
• Word processors, compilers, web browsers, database systems, video games
• Users
• People, machines, other computers
Four Components of a Computer System
Operating System Definition
• OS is a resource allocator
• Manages all resources
• Decides between conflicting requests for efficient and fair resource
use
• OS is a control program
• Controls execution of programs to prevent errors and improper use
of the computer
Operating System Structure
• Multiprogramming (Batch system) needed for efficiency
• Single user cannot keep CPU and I/O devices busy at all times
• Multiprogramming organizes jobs (code and data) so CPU always has one to execute
• A subset of total jobs in system is kept in memory
• One job selected and run via job scheduling
• When it has to wait (for I/O for example), OS switches to another job

• Timesharing (multitasking) is logical extension in which CPU switches jobs so frequently that users can
interact with each job while it is running, creating interactive computing
• Response time should be < 1 second
• Each user has at least one program executing in memory process
• If several jobs ready to run at the same time  CPU scheduling
• If processes don’t fit in memory, swapping moves them in and out to run

• Virtual memory allows execution of processes not completely in memory


Memory Layout for Multiprogrammed
System
Process Management
• A process is a program in execution. It is a unit of work within the system.
Program is a passive entity, process is an active entity.
• Process needs resources to accomplish its task
• CPU, memory, I/O, files
• Initialization data
• Process termination requires reclaim of any reusable resources
• Single-threaded process has one program counter specifying location of
next instruction to execute
• Process executes instructions sequentially, one at a time, until completion
• Multi-threaded process has one program counter per thread
• Typically system has many processes, some user, some operating system
running concurrently on one or more CPUs
• Concurrency by multiplexing the CPUs among the processes / threads
Process Management Activities
The operating system is responsible for the following activities in connection with process
management:

• Creating and deleting both user and system processes


• Suspending and resuming processes
• Providing mechanisms for process synchronization
• Providing mechanisms for process communication
• Providing mechanisms for deadlock handling
Memory Management
• To execute a program all (or part) of the instructions must be in memory
• All (or part) of the data that is needed by the program must be in
memory.
• Memory management determines what is in memory and when
• Optimizing CPU utilization and computer response to users
• Memory management activities
• Keeping track of which parts of memory are currently being used and by whom
• Deciding which processes (or parts thereof) and data to move into and out of
memory
• Allocating and deallocating memory space as needed
Storage Management
• OS provides uniform, logical view of information storage
• Abstracts physical properties to logical storage unit - file
• Each medium is controlled by device (i.e., disk drive, tape drive)
• Varying properties include access speed, capacity, data-transfer rate, access
method (sequential or random)

• File-System management
• Files usually organized into directories
• Access control on most systems to determine who can access what
• OS activities include
• Creating and deleting files and directories
• Primitives to manipulate files and directories
• Mapping files onto secondary storage
• Backup files onto stable (non-volatile) storage media
Mass-Storage Management
• Usually disks used to store data that does not fit in main memory or
data that must be kept for a “long” period of time
• Proper management is of central importance
• Entire speed of computer operation hinges on disk subsystem and its
algorithms
• OS activities
• Free-space management
• Storage allocation
• Disk scheduling
• Some storage need not be fast
• Tertiary storage includes optical storage, magnetic tape
• Still must be managed – by OS or applications
• Varies between WORM (write-once, read-many-times) and RW (read-write)
Protection and Security
• Protection – any mechanism for controlling access of processes or users
to resources defined by the OS
• Security – defense of the system against internal and external attacks
• Huge range, including denial-of-service, worms, viruses, identity theft, theft of
service
• Systems generally first distinguish among users, to determine who can
do what
• User identities (user IDs, security IDs) include name and associated number, one
per user
• User ID then associated with all files, processes of that user to determine access
control
• Group identifier (group ID) allows set of users to be defined and controls
managed, then also associated with each process, file
• Privilege escalation allows user to change to effective ID with more rights
UNIX
• Unix and Unix-like operating systems are a family of computer
operating systems that are derived from the original Unix System from
Bell Labs.

• Ken Thompson, Dennis Ritchie, and others developed the basic


building blocks of Unix including a hierarchical file system, i.e, the
concepts of processes and a command line interpreter for the PDP-7.
From there, multiple generations of Unix were developed for various
machines.
• UNIX is an operating system which was first developed in the 1960s, and
has been under constant development ever since. By operating system, we
mean the suite of programs which make the computer work. It is a stable,
multi-user, multi-tasking system for servers, desktops and laptops.

• UNIX systems also have a graphical user interface (GUI) similar to


Microsoft Windows which provides an easy to use environment. However,
knowledge of UNIX is required for operations which aren't covered by a
graphical program, or for when there is no windows interface available, for
example, in a telnet session.

• The most popular varieties of UNIX are Sun Solaris, GNU/Linux, and
MacOS X.
• The UNIX operating system is made up of three parts; the kernel, the
shell and the programs.

• The kernel of UNIX is the hub of the operating system: it allocates


time and memory to programs and handles the file store and
communications in response to system calls.
• The kernel is the core of the operating system that directly interacts
with the underlying hardware to provide a set of standard services.

• Kernel subsystems may include process management, file


management, memory management, network management and
others.
Example
• 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.
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 our systems).
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. They are created by users using text editors, running
compilers etc.
• Examples of files:
• a document (report, essay etc.)
• the text of a program written in some high-level programming language
• instructions comprehensible directly to the machine and incomprehensible to a
casual user, for example, a collection of binary digits (an executable or binary file);
• a directory, containing information about its contents, which may be a mixture of
other directories (subdirectories) and ordinary files.
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 root (written as a slash /
)
The full path to the file report.doc is "/home/its/ug1/ee51vn/report.doc"
22
Features of Unix OS
• Multitasking: A UNIX operating system is a multitasking operating system that allows
you to initiate more than one task from the same terminal so that one task is performed as
a foreground and the other task as a background process.

• Multi-user: UNIX operating system supports more than one user to access computer
resources like main memory, hard disk, tape drives, etc. Multiple users can log on to the
system from different terminals and run different jobs that share the resources of a
command terminal. It deals with the principle of time-sharing. Time-sharing is done by a
scheduler that divides the CPU time into several segments also called a time slice, and
each segment is assigned to each user on a scheduled basis. This time slice is tiny. When
this time is expired, it passes control to the following user on the system. Each user
executes their set of instructions within their time slice.

23
• Portability: This feature makes the UNIX work on different machines
and platforms with the easy transfer of code to any computer system.
Since a significant portion of UNIX is written in C language, and only a
tiny portion is coded in assembly language for specific hardware.

• File Security and Protection: Being a multi-user system, UNIX makes


special consideration for file and system security. UNIX has different
levels of security using assigning username and password to individual
users ensuring the authentication, at the level providing file access
permission viz. read, write and execute and lastly file encryption to
change the file into an unreadable format.
24
• Command Structure: UNIX commands are easy to understand and
simple to use. Example: "cp", mv etc. While working in the UNIX
environment, the UNIX commands are case-sensitive and are entered
in lower case.

• Open Source: UNIX operating system is open source it means it is


freely available to all and is a community-based development project.

25
• Communication: In UNIX, communication is an excellent feature that
enables the user to communicate worldwide. It supports various
communication facilities provided using the write command, mail
command, talk command, etc.

• Accounting: UNIX keeps an account of jobs created by the user. This


feature enhances the system performance in terms of CPU monitoring
and disk space checking. It allows you to keep an account of disk
space used by each user, and the disk space can be limited by each
other. You can assign every user a different disk quota. The root user
can perform these accounting tasks using various commands such as
quota, df, du, etc.
26
• It is a multi-user system where the same resources can be shared by different
users.
• It provides multi-tasking, wherein each user can execute many processes at the
same time.
• It was the first operating system that was written in a high-level language (C
Language). This made it easy to port to other machines with minimum adaptations.
• It provides a hierarchical file structure which allows easier access and maintenance
of data.
• Unix has built-in networking functions so that different users can easily exchange
information.
• Unix functionality can be extended through user programs built on a standard
programming interface.
Unix Architecture
• The main concept that unites all the versions of Unix is the following four basics −
• Kernel − The kernel is the heart of the operating system. It interacts with the
hardware and most of the tasks like memory management, task scheduling and file
management.
• Shell − The shell is the utility that processes your requests. When you type in a
command at your terminal, the shell interprets the command and calls the program
that you want. The shell uses standard syntax for all commands. C Shell, Bourne
Shell and Korn Shell are the most famous shells which are available with most of the
Unix variants.
• Commands and Utilities − There are various commands and utilities which you
can make use of in your day to day activities. cp, mv, cat and grep, etc. are few
examples of commands and utilities. There are over 250 standard commands plus
numerous others provided through 3 rd party software. All the commands come along
with various options.
• Files and Directories − All the data of Unix is organized into files. All files are then
organized into directories. These directories are further organized into a tree-like
structure called the filesystem.
UNIX
UNIX Utility Programs
UNIX Kernel
Processes in Unix
System Calls for Process
Management

s is error code
pid is process id
Residual is the remaining time from the previous alarm
Unix Scheduler

Unix Scheduler is based on a multilevel ques structure


Shell
• The shell provides you with an interface to the UNIX system. It
gathers input from you and executes programs based on that input.
When a program finishes executing, it displays that program's output.

• A shell is an environment in which we can run our commands,


programs, and shell scripts. There are different flavors of shells, just as
there are different flavors of operating systems. Each flavor of shell
has its own set of recognized commands and functions.

36
A kernel is a program that:
• Controls all computer operations.
• Coordinates all executing utilities
• Ensures that executing utilities do not interfere with each other or
consume all system resources.
• Schedules and manages all system processes.

By interfacing with a kernel, a shell provides a way for a user to execute


utilities and programs.

37
Basic Architecture of the Shell

https://www.edureka.co/blog/types-of-shells-in-linux/

38
UNIX Tools and Utilities
• UNIX Tools and Utilities: UNIX system provides various types of tools
and utilities facilities such as UNIX grep, sed and awk, etc. Some of
the general-purpose tools are compilers, interpreters, network
applications, etc. It also includes various server programs which
provide remote and administration services.

39
Shell Types:
In UNIX there are two major types of shells:
• The Bourne shell. If you are using a Bourne-type shell, the default
prompt is the $ character.
• The C shell. If you are using a C-type shell, the default prompt is the %
character.

40
There are again various subcategories for Bourne Shell which are listed
as follows:
• Bourne shell ( sh)
• Korn shell ( ksh)
• Bourne Again shell ( bash)
• POSIX shell ( sh)

The different C-type shells follow:


• C shell ( csh)
• TENEX/TOPS C shell ( tcsh)

41
Bourne Shell (1977)
• It was written by Steve Bourne at AT&T Bell Labs.
• It is the original UNIX shell.
• It is faster and more preferred.
• It lacks features for interactive use like the ability to recall previous
commands.
• It also lacks built-in arithmetic and logical expression handling. It is
default shell for Solaris OS.
• The Bourne shell led to the development of the many shells that we
use today.

42
• The Bourne shell is the Solaris OS default shell. It is the standard shell
for Solaris system administration scripts. For the Bourne shell the:
• Command full-path name is /bin/sh and /sbin/sh.
• Non-root user default prompt is $.
• Root user default prompt is #.

43
Drawback
• A Bourne shell drawback is that it lacks features for interactive use,
such as the ability to recall previous commands (history). The Bourne
shell also lacks built-in arithmetic and logical expression handling.

44
The C Shell (1978)
• The C shell (csh):
• Is a UNIX enhancement written by Bill Joy at the University of
California at Berkeley.
• Incorporated features for interactive use, such
as aliases and command history.
• Includes convenient programming features, such as built-in
arithmetic and a C-like expression syntax.

45
For the C shell the:
• Command full-path name is /bin/csh.
• Non-root user default prompt is hostname %.
• Root user default prompt is hostname #.

46
The Korn Shell (1983)
• It Was written by David Korn at AT&T Bell Labs. It is a superset of the
Bourne shell.
• combined features of both Bourne Shell and C Shell.
• So it supports everything in the Bourne shell. It included features from
the C Shell such as job control, command aliasing & command history.
• It has interactive features.
• It includes features like built-in arithmetic and C-like arrays, functions,
and string-manipulation facilities.
• It is faster than C shell. It is compatible with script written for C shell.
• Runs scripts written for the Bourne shell.

47
The Korn shell includes features from other shells and provides several
more advanced features found in modern scripting languages such as;
• associative arrays
• floating point arithmetic
• job control
• command aliasing
• command history
• supports POSIX standards
• backward compatibility with bash

48
For the Korn shell the:
• Command full-path name is /bin/ksh.
• Non-root user default prompt is $.
• Root user default prompt is #.

49
GNU Bourne-Again Shell (1989)
• It is compatible to the Bourne shell. It includes features from Korn and
Bourne shell.
• Is compatible to the Bourne shell.
• Incorporates useful features from the Korn and C shells.
• Has arrow keys that are automatically mapped for command recall
and editing.

50
It is also a sh-compatible shell and offers practical improvements over
sh for programming and interactive use which includes:
• Command line editing
• Job Control
• Unlimited size command history
• Shell Functions and Aliases
• Unlimited size Indexed arrays
• Integer arithmetic in any base from two to sixty-four

51
For the GNU Bourne-Again shell the:
• Command full-path name is /bin/bash.
• Default prompt for a non-root user is bash-x.xx$. (Where x.xx
indicates the shell version number. For example, bash-3.50$)
• Root user default prompt is bash-x.xx#. (Where x.xx indicates the
shell version number. For example, bash-3.50$#)

52
TENEX C Shell
• Tcsh is enhanced C shell, it can be used as an interactive login shell
and shell script command processor.
Tcsh has the following features:
• C like syntax
• Command-line editor
• Programmable word and filename completion
• Spelling correction
• Job control

53
Comparison
Shell Path Default Prompt Default Prompt
(non-root user) (Root user)

The Bourne Shell /bin/sh and /sbin/sh $ #


(sh)
The C Shell (csh) /bin/csh % #

The Korn Shell (ksh) /bin/ksh $ #

The GNU Bourne- /bin/bash bash-x.xx$ bash-x.xx#


Again Shell (Bash)

54
Flavors of UNIX
• These can be grouped into two categories: Open Source and Proprietary
• Proprietary: (redistribution and modification prohibited or restricted; not free)
• Solaris - Access to a Solaris UNIX server (solaris.gl.umbc.edu) via SSH access.
• IRIX - There are a couple of IRIX machines in the basement of the library, as well as server access (irix.gl.umbc.edu)
via SSH access.
• Mac OS X - no access currently available at UMBC.
• and many others...

• Open Source: (source code is readily available and free to modify)


• FreeBSD - no access currently available at UMBC.
• Linux Distributions - access is available in the form of dual-boot PCs scattered throughout the Engineering building.
There are also several Linux servers (linux.gl.umbc.edu) through which access is available.
• RedHat (used by UMBC) and the Fedora Project (maintained by RedHat)
• Mandrake
• Debian
• SuSE
• Slackware
• and many others...
• As a side note, Linux is a open source UNIX-based OS that was originally developed in 1991 by Linus Torvalds, a Finnish
undergraduate student.
UNIX History
• The UNIX operating system was born in the late 1960s. It originally began as a
one man project led by Ken Thompson of Bell Labs, and has since grown to
become the most widely used operating system.
• In the time since UNIX was first developed, it has gone through many different
generations and even mutations.
• Some differ substantially from the original version, like Berkeley Software Distribution (BSD)
or Linux.
• Others, still contain major portions that are based on the original source code.
• An interesting and rather up-to-date timeline of these variations of UNIX can be
found at http://www.levenez.com/unix/history.html.
History of Unix
Graphical User Interfaces (GUIs)
• When you logon locally, you are presented with graphical
environment.
• You start at a graphical login screen. You must enter your username
and password. You also the have the option to choose from a couple
session types. Mainly you have the choice between Gnome and KDE.
• Once you enter in your username and password, you are then
presented with a graphical environment that looks like one of the
following...
Gnome
KDE
Command Line Interface
• You also have access to some UNIX servers as well.
• You can logon from virtually any computer that has internet access whether it
be Windows, Mac, or UNIX itself.
• In this case you are communicating through a local terminal to one of
these remote servers.
• All of the commands actually execute on the remote server.
• It is also possible to open up graphical applications through this window, but
that requires a good bit more setup and software. (Time permitting, we may
cover how to do this.)
The Terminal
Why UNIX as an Operating
System (OS)
• Multi-user & Multi-tasking - most versions of UNIX are capable of allowing multiple users to log
onto the system each capable of running multiple tasks. This is standard for almost any OS now-a-
days.
• Over 30 Years Old - there is something to be said for the fact that UNIX is over 30 years old and
it's popularity and use are at all time highs. Over these 30 years many variations have spawned
off and many have died off, but much of todays modern UNIX systems can be traced back to the
original versions. It has endured the test of time. For reference, Windows at best is half as old
(Windows 1.0 was released in the mid 80's, but many would argue that it was not by any means
stable or complete enough until the 3.x family which was released in the early 90's).
• Large Number of Applications - although it may not seem it, there is an enormous amount of
applications available for UNIX operating systems. They range from commercial applications such
as CAD, Maya, Word-perfect, to many free applications.

63
• Free Applications and Even Free Operating System - of all of the applications available
under UNIX, many of them are free. The compilers and interpreters that we use in most
of the programming courses here at UMBC now these free versions that can be
downloaded off of the Internet free of charge. As well, most of the development that we
do in programming courses is done under the Linux OS. Since Linux is one of the free
versions of UNIX, it too can be downloaded and installed free of charge.
• Less Resource Intensive - in general, most UNIX installations tend to be much less
demanding on the system resources. In many cases the old family computer, that can
barely run whatever version of windows is more than sufficient to run the latest version
of Linux.
• Internet Development - Much of the backbone of the Internet is run by UNIX servers of
one type or another. Many of the more general web-servers out there also run UNIX
with the Apache webserver - another free application.

64
quiz
• https://
app.quizalize.com/dash/R3JvdXA6OWU1Y2ViMTctNjM0OS00M2Q2L
WE3YmYtZDMzNGViYWYyYjZm/activity/QWN0aXZpdHk6NjdjMzk1ZDg
tYTYxMC00NzlmLTlkZTAtNDY5MWQxOTBjZjc4/overview

65

You might also like