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

UNIX and Shell Scripting - Module 2

Uploaded by

sr_saurab8511
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
100 views

UNIX and Shell Scripting - Module 2

Uploaded by

sr_saurab8511
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 44

UNIX and Shell Scripting

Module 2: UNIX Operating System


Architecture

Copyright © 2009 Accenture All Rights Reserved. Accenture, its logo, and Accenture High Performance Delivered are trademarks of Accenture.
Module 2 Objectives
• Upon completing this module, the learner will be able to:
– Describe Onion Architecture of UNIX Operating System
– Explain the Interaction of User App with Kernel
– Describe the Hierarchical Structure of UNIX File System (Virtual File
System)
– Describe the Physical file System
– Define a Program
– Define a Process
– Summarize the difference between Program and Process
– Describe working of Shell
– Describe different flavors of UNIX
– List the services offered by UNIX Operating System

Copyright © 2009 Accenture All Rights Reserved. 2


Module 2 Agenda
Topic Name Duration
Introduction to UNIX OS Architecture 30 min

UNIX File System 20 min

Processing Environment 35 min

Operating System Services 25 min

Copyright © 2009 Accenture All Rights Reserved. 3


Introduction to UNIX OS Architecture
• An Operating System (OS) is
a software component of a
computer system, which: Applications
Monitor
– Shares the limited resources
of the computer
– Coordinates and manages the Operating
various activities Printer System
Disk
– Offers a number of services to
Drive
application programs and
users
Keyboard
– Acts as a host for Applications
that are run on the machine

Copyright © 2009 Accenture All Rights Reserved. 4


Discussion: Features of UNIX OS (1 of 2)
• Discussion topic:
– What are the features of UNIX OS?

• Discussion time:
– 5 minutes

• Instructions:
– Ask students about their
experience/opinions.
– Write them on a flip-chart.

Copyright © 2009 Accenture All Rights Reserved. 5


Features of UNIX OS (2 of 2)
• Multi-user, Multi-tasking, Time sharing system
• File structure
• Modularity
• Input/Output Redirection and Pipes
• Consistent Peripheral Interface
• Security
• Communication and Networking
• UNIX Utilities and Software Development Tools

Copyright © 2009 Accenture All Rights Reserved. 6


UNIX Onion Architecture (1 of 2)

User Process
Shell
Shell

Shell
Shell
User Process
Everything below the It provides file
system call interface system, CPU
and above the physical scheduling, memory
hardware is the management, and
KERNEL. other OS functions
using system calls.
Copyright © 2009 Accenture All Rights Reserved. 8
UNIX Onion Architecture (2 of 2)

User Process
Shell
Shell

Shell
The system call Shell
User Process
System call provides a
interface layer programming interface
converts a process that allows user
running in user mode programs to access
to a protected kernel kernel functions.
mode process.
Copyright © 2009 Accenture All Rights Reserved. 9
User Application and Kernel Interaction
Utilities are User Users enter UNIX commands or
set of UNIX run different software applications.
commands
and Programs.
Applications
Applications are different
softwares run on UNIX.

Utility Shell
Shell is a command
interpreter of UNIX.

Kernel
Kernel controls the underlying
The Operating System hardware. The kernel provides
low-level device, memory, and
processor management functions.

Hardware
Copyright © 2009 Accenture All Rights Reserved. 10
Knowledge Check (1 of 3)
• Which of the following are true about the operating system?

1. It manages memory.
2. It manages processor.
3. It manages Input/Output devices.

Copyright © 2009 Accenture All Rights Reserved. 11


Knowledge Check (2 of 3)
• The operating system comprises a set of software packages
that can be used to manage interactions with the hardware.
The elements that are generally included in this set of software
are listed below. Which is the odd one out?

1. Input/Output Devices
2. Shell
3. File System
4. Kernel

Copyright © 2009 Accenture All Rights Reserved. 12


Knowledge Check (3 of 3)
• What are system calls?
• Describe their uses.

Copyright © 2009 Accenture All Rights Reserved. 13


Module 2 Agenda
Topic Name Duration
Introduction to UNIX OS Architecture 30 min

UNIX File System 20 min

Processing Environment 35 min

Operating System Services 25 min

Copyright © 2009 Accenture All Rights Reserved. 14


UNIX File System (1 of 3)
• What is a file?
– A collection of data items stored on a disk

• What is a file system?


– A group of files and relevant information regarding them
– Each file system is stored in a separate whole disk partition
– UNIX supports variety of files
• Ordinary file
• Directory file
• Special files
• Character special files
• Block special files

Copyright © 2009 Accenture All Rights Reserved. 15


Demonstration: UNIX File System (2 of 3)
• For slide 17

• This topic includes demonstration related to login to the UNIX


system and files in a directory. It will be conducted in the
following manner:
– Instructions:
• Explain the command with demonstration.
• Ask participants to execute the same.
• Discuss the related slide.

– Note: The commands would be used by the faculty and participants


simultaneously.

Copyright © 2009 Accenture All Rights Reserved. 16


UNIX File System (3 of 3)
• $ ls –l
– Gives long listing of files

Character “–” In the first column


represents that it is an ordinary file.

Character “d” in the first column represents directory file.

Character “l” in the first column


represents TestFln is link for TestF1.
Copyright © 2009 Accenture All Rights Reserved. 17
UNIX System Directories (1 of 4)
bin directory contains the
commands and utilities used by The directory is located at the top of
user day to day. These are the UNIX file system. It is represented
executable “binary files” by the "/" (forward slash) character.

This directory contains special files used to


represent real physical devices such as
printers and terminals. For non-existent
device null is used

Copyright © 2009 Accenture All Rights Reserved. 18


UNIX System Directories (2 of 4)

For system For each user of This directory


administration, this the system, this contains libraries
directory contains directory that are used by
various commands and contains a home various programs
files. One of these directory. and languages.
files, motd, contains a
'message of the day‘,
which is displayed
whenever we log into
the system.

Copyright © 2009 Accenture All Rights Reserved. 19


UNIX System Directories (3 of 4)
• Kernel is loaded in whenever the system is started up called booting of
the system
• It is at the core of each UNIX system
• It manages the entire resources of the system, presenting them to you
and every other user as a coherent system.

This directory acts as a Typically Application


area to store files on programs, language
temporary basis by any dictionaries, and on-line
user. manual pages reside in this
directory. This also contains
system files and directories
which user wants to share
Copyright © 2009 Accenture All Rights Reserved.
with other users. 20
UNIX System Directories (4 of 4)
• Under the root directory, subdirectories organize the files and
subdirectories on the system. These subdirectories might be of
any name.
• The diagram below represents file structure as inverted tree.

etc bin tmp users src

webmin usb tdlibuser User 1 User 2

Copyright © 2009 Accenture All Rights Reserved. 21


Physical File System
• Storage space on a computer usually resides on several devices
and encompasses different types of media, including hard
drives, CD-ROM drives, and floppy drives. Each of these
devices has a distinct physical file system associated with it.
• There are numerous types of physical file systems found under
UNIX, including:
– ufs
• The standard UNIX File System
– bffs
• The Berkeley Fat Fast File System, an improvement over the original
UNIX file system
– cd9660
• The ISO-9660 file system for CD-ROM drives
• The types of file systems available vary from OS to OS and
cover a wide variety of devices and media.
Copyright © 2009 Accenture All Rights Reserved. 22
Module 2 Agenda
Topic Name Duration
Introduction to UNIX OS Architecture 30 min

UNIX File System 20 min

Processing Environment 35 min

Operating System Services 25 min

Copyright © 2009 Accenture All Rights Reserved. 23


Discussion: Program in Execution (1 of 3)
• Discussion topic:
– What kind of programs have you
written?

• Discussion time:
– 5 minutes

• Instructions:
– Ask students about their
experience/opinions.
– Write them on a flip-chart.

Copyright © 2009 Accenture All Rights Reserved. 24


Program in Execution (2 of 3)
List of Processes Before Running program

List of Processes After Running program

New process Created for the running program

Copyright © 2009 Accenture All Rights Reserved. 25


Demonstration: Program in Execution
(3 of 3)
• This topic includes demonstration on Program (Focus:
Functionality). It will be conducted in the following manner:
– Instructions:
• Explain the command with demonstration.
• Ask participants to execute the same.
• Discuss the related slide.

– Note: The commands would be used by the faculty and participants


simultaneously.

Copyright © 2009 Accenture All Rights Reserved. 26


Processing Environment
• A program is a set of instructions written to perform a specific
task.

• A process is:
– An operation which takes the instructions given and does the
manipulations or anything that is instructed in the code itself
– The single executable module that runs concurrently with other
executable modules
– A program in execution

Copyright © 2009 Accenture All Rights Reserved. 27


Shell as Command Interpreter
• Each line that shell reads from standard input is called a pipeline.
• Shell as a command interpreter:
– Reads lines from standard input (each of these line is called pipeline)
– Splits the command into tokens
– Checks the token to see if it’s a keyword
– Checks the first word for alias
– Performs command substitution for any $(string)
– Performs wildcard expansion
– Looks at first word as build-in command
– Runs the command

• For example, following command on command prompt:


ll $(whence cc) /etc/pass*
will change to ls –l /bin/cc /etc/passwd
– if ll is alias to ls –l
– cc is in /bin directory
– /etc directory has only one file starting with string “pass”

Copyright © 2009 Accenture All Rights Reserved. 28


Knowledge Check (1 of 5)
• Find the odd one out:

1. Block Special Files


2. Character Special Files
3. Disk Files
4. Ordinary Files
5. Directory Files

Copyright © 2009 Accenture All Rights Reserved. 29


Knowledge Check (2 of 5)
• State whether the following statements are True or False:

1. When you log into your UNIX account, you are placed in your
“pwd” directory.
2. The types of file systems available vary from OS to OS.

Copyright © 2009 Accenture All Rights Reserved. 30


Knowledge Check (3 of 5)
• Which of the following command should be used to move to the
directory above the current directory?

1. cd
2. cd ..
3. cd..
4. None

Copyright © 2009 Accenture All Rights Reserved. 31


Knowledge Check (4 of 5)
• What is the command used to see all the processes running
currently?

1. ps
2. ls
3. cd
4. ls –l

Copyright © 2009 Accenture All Rights Reserved. 32


Knowledge Check (5 of 5)
• State whether the following statements are True or False:

1. Basic and other commands are available in bin directory.


2. Shell is also a program which keeps on running till user login.
3. Every word written on command line is command for shell.
4. UNIX allows other processes to run while running one.
5. Process is an executable module.

Copyright © 2009 Accenture All Rights Reserved. 33


Module 2 Agenda
Topic Name Duration
Introduction to UNIX OS Architecture 30 min

UNIX File System 20 min

Processing Environment 35 min

Operating System Services 25 min

Copyright © 2009 Accenture All Rights Reserved. 34


Discussion: UNIX Variants (1 of 3)
• Discussion topic:
– How many different UNIX variants have
you heard of?

• Discussion time:
– 5 minutes

• Instructions:
– Ask students about their
experience/opinions.
– Write them on a flip-chart.

Copyright © 2009 Accenture All Rights Reserved. 35


UNIX Variants (2 of 3)
• UNIX Variants

Year UNIX Variant Features


1957 BESYS • At Bell Labs
• To run batch jobs
1965 MULTICS • Adopted third generation computer
(Multiplexed Information and equipments
Computing Service)
1969 UNICS • To play space travel on another
(UNiplexed Information and smaller machine (DEC PDP-7)
Computing Service)
1971 UNIX • The first edition of the "UNIX
PROGRAMMER'S MANUAL”
– By K. Thompson [and] D. M. Ritchie;
included over 60 commands

Copyright © 2009 Accenture All Rights Reserved. 36


UNIX Variants (3 of 3)
• UNIX Popular Variants
UNIX Variant Features
AIX • Developed By IBM in 1990
(Advanced Interactive eXecutive) • Shells available (Korn, Bourne, C)
• Default Korn shell
BSD • Developed at the Computer System
(Berkeley Software Distribution) Research Group (CSRG)

Sun Solaris • Sun company's UNIX variant operating


system

MINIX • A free UNIX clone written from scratch


• Small size
• Micro kernel-based design and simple
documentation
• Suited for personal computer

Copyright © 2009 Accenture All Rights Reserved. 37


LINUX
• Developed by Linus Torvalds

• Freely available multitasking and multi-user operating system

• Placed under General Public License

• Variants
– Caldera Linux
– Debian Linux
– Kondara Linux
– Red Hat Linux
– Mandrake Linux
– SuSE Linux

Copyright © 2009 Accenture All Rights Reserved. 38


UNIX Flavors
• All proprietary UNIX flavors and their names are respective
trademarks of the originating entity/vendor.

Originator Proprietary Name


U. Cal. Berkley BSD
Sun Solaris
IBM AIX
HP HP - UX
SGI IRIX
Digital Equipment2 DEC UNIX
Compaq Tru64 UNIX3
Apple MacOS X4
L. Torvalds/GNU5 Linux6
Copyright © 2009 Accenture All Rights Reserved. 39
Kernel (1 of 2)
• Kernel is the heart of OS and performs various operations on
behalf of the user processes, like:
– Permitting process controlled access
• Devices like terminals
• Disk and tape drives
• Network drives
– Controlling the process execution
• Creation
• Termination
• Suspension
• Communication

Copyright © 2009 Accenture All Rights Reserved. 40


Kernel (2 of 2)
– Efficient retrieval and storage of user data
• By allocating storage
• By reclaiming unused storage
• Protecting
– Time sharing
• Suspending the process
• Rescheduling the processes
– Sharing of main memory
• Swapping system

Copyright © 2009 Accenture All Rights Reserved. 41


Knowledge Check (1 of 2)
• Which one from the following service support more than one
user to use the UNIX system at the same time?

1. Modularity
2. File Structure
3. Multitasking
4. Input-Output Redirections and Pipes

Copyright © 2009 Accenture All Rights Reserved. 42


Knowledge Check (2 of 2)
• State whether the following statements are True or False:

1. Portability is the ability of software to operate on different types of


machines (often called platforms).
2. In UNIX systems, a user can initiate more than one task to run at a
time from the same terminal.
3. UNIX has a hierarchical file structure. It is like an inverted tree,
having the Child at the top.
4. A UNIX system consists of various tools that help the programmers
to develop different applications.

Copyright © 2009 Accenture All Rights Reserved. 43


Module 2 Summary
• Upon completing this module, you should now be able to:
– Describe Onion Architecture of UNIX Operating System
– Explain the Interaction of User App with Kernel
– Describe the Hierarchical Structure of UNIX File System (Virtual File
System)
– Describe the Physical file System
– Define a Program
– Define a Process
– Summarize the difference between Program and Process
– Describe working of Shell
– Describe different flavors of UNIX
– List the services offered by UNIX Operating System

Copyright © 2009 Accenture All Rights Reserved. 44


Questions and Comments
• What questions or comments
do you have?

Copyright © 2009 Accenture All Rights Reserved. 45

You might also like