Introduction To Unix1
Introduction To Unix1
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
• 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.
• 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.
• 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.
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.
s is error code
pid is process id
Residual is the remaining time from the previous alarm
Unix Scheduler
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.
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)
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)
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...
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