UNIX and Shell Scripting_Module 2

download UNIX and Shell Scripting_Module 2

of 44

Transcript of UNIX and Shell Scripting_Module 2

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    1/44

    Training Partner

    UNIX and Shell Scripting

    Module 2: UNIX Operating SystemArchitecture

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    2/44

    Training Partner

    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 (VirtualFile 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

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    3/44

    Training Partner

    Module 2 Agenda

    Topic Name Duration

    Introduction to UNIX OS Architecture 30 min

    UNIX File System 20 min

    Processing Environment 35 minOperating System Services 25 min

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    4/44

    Training Partner 4

    Introduction to UNIX OS Architecture

    An Operating System (OS)is a software component ofa computer system, which: Shares the limited resources

    of the computer

    Coordinates and managesthe various activities

    Offers a number of servicesto application programs andusers

    Acts as a host forApplications that are run onthe machine

    Printer

    Monitor Applications

    DiskDrive

    Keyboard

    Operat ing

    System

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    5/44

    Training Partner

    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.

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    6/44

    Training Partner

    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

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    7/44Training Partner 8

    UNIX Onion Architecture (1 of 2)

    8

    Shell

    Shell

    User Process

    Shell

    User Process

    Shell

    Everything below thesystem call interfaceand above thephysical hardware isthe KERNEL.

    It provides filesystem, CPUscheduling, memorymanagement, andother OS functions

    using system calls.

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    8/44Training Partner 9

    UNIX Onion Architecture (2 of 2)

    Shell

    Shell

    User Process

    Shell

    User Process

    Shell

    The system callinterface layerconverts a processrunning in user modeto a protected kernelmode process.

    System call provides aprogramming interfacethat allows userprograms to accesskernel functions.

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    9/44Training Partner

    User Application and Kernel Interaction

    Kernelcontrols the underlyinghardware. The kernel provideslow-level device, memory, andprocessor management functions.

    Shellis a commandinterpreter of UNIX.

    Utilities areset of UNIXcommandsand Programs.

    Hardware

    KernelThe Operating System

    ShellUtility

    Applications

    User

    Applications are differentsoftwares run on UNIX.

    Usersenter UNIX commands orrun different software applications.

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    10/44

    Training Partner

    Knowledge Check (1 of 3)

    Which of the following are true about the operatingsystem?

    1. It manages memory.

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

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    11/44

    Training Partner 12

    Knowledge Check (2 of 3)

    The operating system comprises a set of softwarepackages that can be used to manage interactions withthe hardware. The elements that are generally included inthis set of software are listed below. Which is the odd oneout?

    1. Input/Output Devices

    2. Shell

    3. File System

    4. Kernel

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    12/44

    Training Partner 13

    Knowledge Check (3 of 3)

    What are system calls? Describe their uses.

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    13/44

    Training Partner 14

    Module 2 Agenda

    Topic Name Duration

    Introduction to UNIX OS Architecture 30 min

    UNIX File System 20 min

    Processing Environment 35 minOperating System Services 25 min

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    14/44

    Training Partner

    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

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    15/44

    Training Partner 16

    Demonstration: UNIX File System (2 of 3)

    For slide 17

    This topic includes demonstration related to login to the UNIX systemand 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 participantssimultaneously.

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    16/44

    Training Partner 17

    UNIX File System (3 of 3)

    $ lsl Gives long listing of files

    Character In the first column

    represents that it is an ordinary file.

    Character l in the first column

    represents TestFln is link for TestF1.

    Character d in the first column represents directory file.

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    17/44

    Training Partner 18

    UNIX System Directories (1 of 4)

    bin directory contains thecommands and utilities used byuser day to day. These areexecutable binary files

    The directory is located at the top ofthe UNIX file system. It is representedby the "/" (forward slash) character.

    This directory contains special files used torepresent real physical devices such asprinters and terminals. For non-existentdevice null is used

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    18/44

    Training Partner 19

    UNIX System Directories (2 of 4)

    For systemadministration, thisdirectory containsvarious commands andfiles. One of thesefiles, motd, contains a'message of the day,

    which is displayedwhenever we log intothe system.

    For each user ofthe system, thisdirectorycontains a homedirectory.

    This directorycontains librariesthat are used byvarious programsand languages.

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    19/44

    Training Partner 20

    UNIX System Directories (3 of 4)

    Kernel is loaded in whenever the system is started up called booting ofthe system

    It is at the core of each UNIX system It manages the entire resources of the system, presenting them to youand every other user as a coherent system.

    This directory acts as aarea to store files ontemporary basis by anyuser.

    Typically Application

    programs, languagedictionaries, and on-linemanual pages reside in thisdirectory. This also containssystem files and directorieswhich user wants to share

    with other users.

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    20/44

    Training Partner 21

    UNIX System Directories (4 of 4)

    Under the root directory, subdirectories organize the filesand subdirectories on the system. These subdirectoriesmight be of any name.

    The diagram below represents file structure as invertedtree.

    /

    etc bin tmp users src

    webmin usb tdlibuser User 1 User 2

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    21/44

    Training Partner

    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 ofdevices and media.

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    22/44

    Training Partner 23

    Module 2 Agenda

    Topic Name DurationIntroduction to UNIX OS Architecture 30 min

    UNIX File System 20 min

    Processing Environment35 min

    Operating System Services 25 min

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    23/44

    Training Partner 24

    Discussion: Program in Execution (1 of 3)

    Discussion topic: What kind of programs have youwritten?

    Discussion time:

    5 minutes

    Instructions:

    Ask students about their

    experience/opinions. Write them on a flip-chart.

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    24/44

    Training Partner

    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

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    25/44

    Training Partner 26

    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 participantssimultaneously.

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    26/44

    Training Partner 27

    Processing Environment

    A program is a set of instructions written to perform aspecific 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 otherexecutable modules

    A program in execution

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    27/44

    Training Partner 28

    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 its 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 lsl /bin/cc /etc/passwd if ll is alias to lsl

    cc is in /bin directory

    /etc directory has only one file starting with string pass

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    28/44

    Training Partner 29

    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

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    29/44

    Training Partner 30

    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 pwddirectory.

    2. The types of file systems available vary from OS to OS.

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    30/44

    Training Partner 31

    Knowledge Check (3 of 5)

    Which of the following command should be used to moveto the directory above the current directory?

    1. cd

    2. cd ..

    3. cd..

    4. None

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    31/44

    Training Partner

    Knowledge Check (4 of 5)

    What is the command used to see all the processesrunning currently?

    1. ps2. ls

    3. cd4. lsl

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    32/44

    Training Partner 33

    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.

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    33/44

    Training Partner 34

    Module 2 Agenda

    Topic Name DurationIntroduction to UNIX OS Architecture 30 min

    UNIX File System 20 min

    Processing Environment 35 min

    Operating System Services 25 min

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    34/44

    Training Partner 35

    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.

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    35/44

    Training Partner 36

    UNIX Variants (2 of 3)

    UNIX VariantsYear UNIX Variant Features

    1957 BESYS At Bell Labs

    To run batch jobs

    1965 MULTICS(Multiplexed Information andComputing Service)

    Adopted third generation computerequipments

    1969 UNICS

    (UNiplexed Information andComputing Service)

    To play space travel on anothersmaller machine (DEC PDP-7)

    1971 UNIX The first edition of the "UNIXPROGRAMMER'S MANUAL

    By K. Thompson [and] D. M. Ritchie;included over 60 commands

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    36/44

    Training Partner 37

    UNIX Variants (3 of 3)

    UNIX Popular VariantsUNIX Variant FeaturesAIX

    (Advanced Interactive eXecutive)

    Developed By IBM in 1990

    Shells available (Korn, Bourne, C)

    Default Korn shell

    BSD(Berkeley Software Distribution)

    Developed at the Computer SystemResearch Group (CSRG)

    Sun Solaris Sun company's UNIX variant operatingsystem

    MINIX A free UNIX clone written from scratchSmall size

    Micro kernel-based design and simpledocumentation

    Suited for personal computer

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    37/44

    Training Partner

    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

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    38/44

    Training Partner 39

    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 SolarisIBM AIX

    HP HP - UX

    SGI IRIX

    Digital Equipment2 DEC UNIXCompaq Tru64 UNIX3

    Apple MacOS X4

    L. Torvalds/GNU5 Linux6

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    39/44

    Training Partner

    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

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    40/44

    Training Partner 41

    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

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    41/44

    Training Partner

    Knowledge Check (1 of 2)

    Which one from the following service support more thanone user to use the UNIX system at the same time?

    1. Modularity

    2. File Structure

    3. Multitasking

    4. Input-Output Redirections and Pipes

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    42/44

    Training Partner 43

    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 ofmachines (often called platforms).

    2. In UNIX systems, a user can initiate more than one task to run at atime 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 programmersto develop different applications.

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    43/44

    Training Partner

    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

  • 8/11/2019 UNIX and Shell Scripting_Module 2

    44/44

    Questions and Comments

    What questions orcomments do you have?