SlideShare ist ein Scribd-Unternehmen logo
1 von 33
Downloaden Sie, um offline zu lesen
Operating Systems
            Part II: Introduction to
            the Unix Operating
            System
            (Utilities and Shell
            Programming)




1
Unix Design Principles
     Time-sharing   system
     Supports multiple processes
     Simplicity is key -> kernel provides small set of
      functionality
     Source code provided with O/S
     Designed by programmers for programmers
      (i.e. programmable shell, make, SCCS)


2
Unix Design Principles
     Unix later used for networking, graphics, real-
      time operation (not part of the original
      programming objective)
     New functionality required large amount of
      code (networking, GUI doubled the size of the
      system)
     Continued strength -> even with new
      development, system still remained Unix

3
Programmer Interface

                                         (The users)
                                     shells and commands
                                   compilers and interpreters
                                        system libraries
                                system interface to the kernel

        swapping                                                demand paging
        disk and tape drivers
        virtual memory
                                          kernel                file system
                                                                page replacement
        CPU scheduling                                          signals


                           kernel interface to the hardware
                                        hardware
4
The Unix Shell
     Command        interpreter
      –    Most common user interface
      –    Normally executes user-written and system
           programs
      –    Called shell in Unix because it surrounds the kernel
     In   Unix, users can write their own shell




5
The Unix Shell
     Most   popular Unix shells:
      –   Bourne shell (Steve Bourne, prompt is ‘$’)
      –   C shell (Bill Joy, most popular on BSD systems,
          prompt is ‘%’)
      –   Korn shell (Dave Korn, became popular because it
          combines features of C and Bourne shells, prompt
          is ‘$’)
     Unix   GUIs: X, OpenView, Motif


6
The Unix Shell
     Users  can create programs using shell scripts
      (equivalent to batch files in MS-DOS)
     Most popular Unix shells are also programming
      languages complete with variables and control
      constructs (loops, conditional, etc.)
     Shell programming can be used to create
      another shell



7
Unix Commands
     Commands    all have the same structure
     Case-sensitive! (cd <> CD, unlike in MS-DOS)
     The number of commands kept small but each
      command is extended through
      options/switches (preceded by ‘-’)




8
Unix Commands
     Example
      –   Basic directory command: ls (lists all contents of a
          directory)
      –   Extended command: ls -l (lists contents plus
          other file information)




9
The Unix File System
      Features    of the Unix File System
       –   Hierarchical structure (similar to MS-DOS)
       –   Files are expandable (may grow are required)
       –   Security rights associated w/ each file/ directory
             Incorporates  three-tiered structure on file access
             9 bits (User-Group-Others, rwxrwxrwx)
             Access types (r - Read, w - Write, x - Execute, ‘-’ means
              no access)
            -rwx---r-x 1 aam faculty 37 May 06 7:35 test
       –   Files may be shared (concurrent access)


10
The Unix File System
      Features    of Unix File System (continued)
       –   Various information kept for each file (i.e. name,
           location, size, owner, security, modified by, last
           access by, date & time stamp, etc.)
       –   File links - mechanism that allows multiple file
           names to refer to the same data on the storage
           device




11
The Unix File System
      Most   often used file system commands:
       –   pwd (present working directory)
       –   cd (change directory)
       –   mkdir (create directory)
       –   rmdir (remove directory)
       –   ls (list directory contents)
       –   cat (concatenate files) / more (pauses after screen
           is full)
       –   cp (copy file)


12
The Unix File System
      Most   often used file system commands:
       –   vi (edit a file)
       –   mv (move a file)
       –   rm (remove file)
       –   ln (create link)
       –   chmod (change file access mode)
       –   chown (change file owner -> can be done only by
           “root”/file owner
       –   cmp / diff (compare 2 files)


13
Shell Basics
      Shell   variables
       –   Similar to environment variables in MS-DOS
       –   Syntax: varname=value
       –   Preceded by $ when printing value (e.g.
           echo $x, where x is a variable)
       –   Special variable PS1
            Variable   that contains string for command line
             prompt
            May be replaced


14
Shell Basics
      Input/Output    commands
       –   read - get input from keyboard and assign it to a
           variable
       –   echo - send stream of characters to screen
       –   pr - send output to printer




15
Shell Basics
      Command           substitution
       –   The output is taken instead of the command itself
       –   Command is enclosed in `` (e.g. x=`date`)
       –   Common uses:
             Variable
                    assignment
             Command line arguments




16
Shell Basics
      Wildcards
       ?    Matches any single character except a leading ‘.’
         (dot)
       * Matches zero or more characters except a
         leading dot
       [] Defines a class of characters
           -   Defines an inclusive ranges (e.g. [0-9])
           !   Negates the defined class




17
Shell Basics
      Quoting   characters
       Developed because of certain characters have special
        meaning (e.g. $, *, <, >, #, etc.)
        Removes meaning of the next character
       ’ Removes meaning of all characters
       ” Removes meaning of all characters except , $,
        and ”




18
Shell Basics
      Exercise   for quoting characters

       What’s the difference between...

       echo ’$abc’
       echo ”$abc”
       echo $abc



19
Shell Basics
      Redirection
       Every time a shell is started, three files (devices) are
         automatically opened:
       – stdin (standard input) - device from w/c the program
         reads the input (keyboard), file descriptor 0
       – stdout (standard output) - device to w/c the
         program writes the output (monitor), file descriptor 1
       – stderr (standard error) - device to w/c the program
         writes the errors (monitor), file descriptor 2


20
Shell Basics
      Redirection    (cont’d)
       –   Redirection - output is written to or read from
           another file instead of the standard files/devices
       –   Syntax: command symbol filename
       –   Input redirection (<) - any command that reads its
           input from stdin can have it read from a file




21
Shell Basics
      Redirection    (cont’d)
       –   Output redirection (> or >>) - any command that
           writes its output to stdout can be redirected to
           create, overwrite, or append to another file
       –   Error redirection (2> or 2>>) - error messages are
           redirected to create, overwrite, or append to another
           file




22
Shell Basics
      Redirection   (cont’d)
       Special redirection commands:
       2>&1 - redirects standard errors on same stream as
         stdout
       1>&2 - redirects outputs to stdout on same stream as
         stderr




23
Shell Basics
      Piping
       –   Sends output of one command as input of another
           command
       –   Syntax: command1 | command2
       –   Eliminates temporary files using redirection
           commands, for example
                $ date > tmpfile
                $ wc tmpfile
                $ rm tmpfile
                Can be written instead as date | wc



24
Shell Basics
      Filters
        –   Program that reads input, performs translation,
            produces output
        –   Commonly used filters:
              grep  (looks for occurrences of words/phrases in files)
              sort (sorts input and writes to the output)
              sed (reads lines from input file, applies edit commands,
               and outputs to stdout)




25
Shell Basics
      Filters   (cont’d)
        –   Commonly used filters
              awk
                 – designed by Al Aho, Peter Weinberger, and Brian Kernighan
                 – much more flexible and addresses limitations of sed
                 – allows programming constructs to be used (looping,
                   variables, arithmetic, etc.)
                 – processing language based on C




26
Shell Programming
      Command      line arguments
       –   Shellscript command parameters are represented
           by $number
       –   Number indicates position of command argument
       –   Example:
            myprog word1 bin
             $1 = word1
             $2 = bin
             $0 = myprog




27
Shell Programming
      Command       line arguments
       –   Other important shell variables related to command
           parameters
            $# the number of arguments
            $* all arguments




28
Shell Programming
      Decision      statements
       –   IF command
            if command
            then
                 commands if condition is true
            else
                 commands if condition is false
            fi




29
Shell Programming
      Decision   statements
       –   CASE command
           case word in
           pattern) commands;;
           pattern) commands;;
           ...
           esac




30
Shell Programming
      Looping     constructs
       –   FOR loop
            for var in list of words
            do
                loop body , $var set to successive elements of the list
            done




31
Shell Programming
      Looping     constructs (cont’d)
       –   WHILE loop
            while command
            do
               loop body executed as long as command is true
            done




32
Shell Programming
      Looping     constructs (cont’d)
       –   UNTIL loop
            until command
            do
               loop body executed as long as command is true
            done
       –   The symbol ‘:’ is a shell built-in that does nothing
           but return true
       –   The command true can also be used
       –   ‘:’ is more efficient since it is not a command


33

Weitere ähnliche Inhalte

Was ist angesagt?

Useful Linux and Unix commands handbook
Useful Linux and Unix commands handbookUseful Linux and Unix commands handbook
Useful Linux and Unix commands handbookWave Digitech
 
Module 02 Using Linux Command Shell
Module 02 Using Linux Command ShellModule 02 Using Linux Command Shell
Module 02 Using Linux Command ShellTushar B Kute
 
Unix reference sheet
Unix reference sheetUnix reference sheet
Unix reference sheetapajadeh
 
Lecture2 process structure and programming
Lecture2   process structure and programmingLecture2   process structure and programming
Lecture2 process structure and programmingMohammed Farrag
 
Linux file commands and shell scripts
Linux file commands and shell scriptsLinux file commands and shell scripts
Linux file commands and shell scriptsPrashantTechment
 
Lecture 4 FreeBSD Security + FreeBSD Jails + MAC Security Framework
Lecture 4 FreeBSD Security + FreeBSD Jails + MAC Security FrameworkLecture 4 FreeBSD Security + FreeBSD Jails + MAC Security Framework
Lecture 4 FreeBSD Security + FreeBSD Jails + MAC Security FrameworkMohammed Farrag
 
Lecture 6 Kernel Debugging + Ports Development
Lecture 6 Kernel Debugging + Ports DevelopmentLecture 6 Kernel Debugging + Ports Development
Lecture 6 Kernel Debugging + Ports DevelopmentMohammed Farrag
 
Unix Shell Script
Unix Shell ScriptUnix Shell Script
Unix Shell Scriptstudent
 
Bash shell scripting
Bash shell scriptingBash shell scripting
Bash shell scriptingVIKAS TIWARI
 
Shell and its types in LINUX
Shell and its types in LINUXShell and its types in LINUX
Shell and its types in LINUXSHUBHA CHATURVEDI
 
Lecture 5 Kernel Development
Lecture 5 Kernel DevelopmentLecture 5 Kernel Development
Lecture 5 Kernel DevelopmentMohammed Farrag
 
Complete Guide for Linux shell programming
Complete Guide for Linux shell programmingComplete Guide for Linux shell programming
Complete Guide for Linux shell programmingsudhir singh yadav
 
Unix Shell Scripting
Unix Shell ScriptingUnix Shell Scripting
Unix Shell ScriptingMustafa Qasim
 
Linux training
Linux trainingLinux training
Linux trainingartisriva
 

Was ist angesagt? (20)

Useful Linux and Unix commands handbook
Useful Linux and Unix commands handbookUseful Linux and Unix commands handbook
Useful Linux and Unix commands handbook
 
Module 02 Using Linux Command Shell
Module 02 Using Linux Command ShellModule 02 Using Linux Command Shell
Module 02 Using Linux Command Shell
 
Unix reference sheet
Unix reference sheetUnix reference sheet
Unix reference sheet
 
Linux Shell Basics
Linux Shell BasicsLinux Shell Basics
Linux Shell Basics
 
Lecture1 Introduction
Lecture1  IntroductionLecture1  Introduction
Lecture1 Introduction
 
Lecture2 process structure and programming
Lecture2   process structure and programmingLecture2   process structure and programming
Lecture2 process structure and programming
 
Linux file commands and shell scripts
Linux file commands and shell scriptsLinux file commands and shell scripts
Linux file commands and shell scripts
 
Lecture 4 FreeBSD Security + FreeBSD Jails + MAC Security Framework
Lecture 4 FreeBSD Security + FreeBSD Jails + MAC Security FrameworkLecture 4 FreeBSD Security + FreeBSD Jails + MAC Security Framework
Lecture 4 FreeBSD Security + FreeBSD Jails + MAC Security Framework
 
Lecture 6 Kernel Debugging + Ports Development
Lecture 6 Kernel Debugging + Ports DevelopmentLecture 6 Kernel Debugging + Ports Development
Lecture 6 Kernel Debugging + Ports Development
 
[ArabBSD] Unix Basics
[ArabBSD] Unix Basics[ArabBSD] Unix Basics
[ArabBSD] Unix Basics
 
Unix Shell Script
Unix Shell ScriptUnix Shell Script
Unix Shell Script
 
Bash shell scripting
Bash shell scriptingBash shell scripting
Bash shell scripting
 
Shell and its types in LINUX
Shell and its types in LINUXShell and its types in LINUX
Shell and its types in LINUX
 
SHELL PROGRAMMING
SHELL PROGRAMMINGSHELL PROGRAMMING
SHELL PROGRAMMING
 
Lecture 5 Kernel Development
Lecture 5 Kernel DevelopmentLecture 5 Kernel Development
Lecture 5 Kernel Development
 
Complete Guide for Linux shell programming
Complete Guide for Linux shell programmingComplete Guide for Linux shell programming
Complete Guide for Linux shell programming
 
Unix system calls
Unix system callsUnix system calls
Unix system calls
 
Unix Shell Scripting
Unix Shell ScriptingUnix Shell Scripting
Unix Shell Scripting
 
Linux training
Linux trainingLinux training
Linux training
 
Linux basic commands
Linux basic commandsLinux basic commands
Linux basic commands
 

Andere mochten auch

Sls01 Lecture02 Linux In Practice
Sls01 Lecture02 Linux In PracticeSls01 Lecture02 Linux In Practice
Sls01 Lecture02 Linux In PracticeQasim Khawaja
 
Impact of Satellite Networks on Transport Layer Protocols
Impact of Satellite Networks on Transport Layer ProtocolsImpact of Satellite Networks on Transport Layer Protocols
Impact of Satellite Networks on Transport Layer ProtocolsReza Gh
 
Linux red hat overview and installation
Linux red hat overview and installationLinux red hat overview and installation
Linux red hat overview and installationdevenderbhati
 
C LANGUAGE - BESTECH SOLUTIONS
C LANGUAGE - BESTECH SOLUTIONSC LANGUAGE - BESTECH SOLUTIONS
C LANGUAGE - BESTECH SOLUTIONSBESTECH SOLUTIONS
 
Unix Introduction
Unix IntroductionUnix Introduction
Unix IntroductionAnanthi
 
Introduction to C programming
Introduction to C programmingIntroduction to C programming
Introduction to C programmingRutvik Pensionwar
 
IP based communications over satellites
IP based communications over satellitesIP based communications over satellites
IP based communications over satellitesBektaş Şahin
 
Structure of c_program_to_input_output
Structure of c_program_to_input_outputStructure of c_program_to_input_output
Structure of c_program_to_input_outputAnil Dutt
 
Flow Chart & Input Output Statement [3] M
Flow Chart & Input Output Statement [3] MFlow Chart & Input Output Statement [3] M
Flow Chart & Input Output Statement [3] Mecko_disasterz
 
Ip Networking Over Satelite Course Sampler
Ip Networking Over Satelite Course SamplerIp Networking Over Satelite Course Sampler
Ip Networking Over Satelite Course SamplerJim Jenkins
 
Java interfaces & abstract classes
Java interfaces & abstract classesJava interfaces & abstract classes
Java interfaces & abstract classesShreyans Pathak
 
10 Principles of Mobile App Design
10 Principles of Mobile App Design10 Principles of Mobile App Design
10 Principles of Mobile App DesignTechAhead
 

Andere mochten auch (20)

Unix Introduction
Unix IntroductionUnix Introduction
Unix Introduction
 
UNIX introduction
UNIX introductionUNIX introduction
UNIX introduction
 
Sls01 Lecture02 Linux In Practice
Sls01 Lecture02 Linux In PracticeSls01 Lecture02 Linux In Practice
Sls01 Lecture02 Linux In Practice
 
Impact of Satellite Networks on Transport Layer Protocols
Impact of Satellite Networks on Transport Layer ProtocolsImpact of Satellite Networks on Transport Layer Protocols
Impact of Satellite Networks on Transport Layer Protocols
 
Unix seminar
Unix seminarUnix seminar
Unix seminar
 
Linux red hat overview and installation
Linux red hat overview and installationLinux red hat overview and installation
Linux red hat overview and installation
 
C LANGUAGE - BESTECH SOLUTIONS
C LANGUAGE - BESTECH SOLUTIONSC LANGUAGE - BESTECH SOLUTIONS
C LANGUAGE - BESTECH SOLUTIONS
 
Unix Introduction
Unix IntroductionUnix Introduction
Unix Introduction
 
Linking in MS-Dos System
Linking in MS-Dos SystemLinking in MS-Dos System
Linking in MS-Dos System
 
Introduction to C programming
Introduction to C programmingIntroduction to C programming
Introduction to C programming
 
IP based communications over satellites
IP based communications over satellitesIP based communications over satellites
IP based communications over satellites
 
Structure of c_program_to_input_output
Structure of c_program_to_input_outputStructure of c_program_to_input_output
Structure of c_program_to_input_output
 
Structure of a C program
Structure of a C programStructure of a C program
Structure of a C program
 
Flow Chart & Input Output Statement [3] M
Flow Chart & Input Output Statement [3] MFlow Chart & Input Output Statement [3] M
Flow Chart & Input Output Statement [3] M
 
Ip Networking Over Satelite Course Sampler
Ip Networking Over Satelite Course SamplerIp Networking Over Satelite Course Sampler
Ip Networking Over Satelite Course Sampler
 
Satellite link design
Satellite link designSatellite link design
Satellite link design
 
Java interfaces & abstract classes
Java interfaces & abstract classesJava interfaces & abstract classes
Java interfaces & abstract classes
 
C material
C materialC material
C material
 
File systems for Embedded Linux
File systems for Embedded LinuxFile systems for Embedded Linux
File systems for Embedded Linux
 
10 Principles of Mobile App Design
10 Principles of Mobile App Design10 Principles of Mobile App Design
10 Principles of Mobile App Design
 

Ähnlich wie Introduction to Unix Operating System Utilities and Shell Programming

Terminal basic-commands(Unix) -partI
Terminal basic-commands(Unix) -partITerminal basic-commands(Unix) -partI
Terminal basic-commands(Unix) -partIKedar Bhandari
 
Linux powerpoint
Linux powerpointLinux powerpoint
Linux powerpointbijanshr
 
Presentation for RHCE in linux
Presentation  for  RHCE in linux Presentation  for  RHCE in linux
Presentation for RHCE in linux Kuldeep Tiwari
 
Introduction to Unix
Introduction to UnixIntroduction to Unix
Introduction to UnixSudharsan S
 
Shell & Shell Script
Shell & Shell ScriptShell & Shell Script
Shell & Shell ScriptAmit Ghosh
 
Shell & Shell Script
Shell & Shell Script Shell & Shell Script
Shell & Shell Script Amit Ghosh
 
Linux Notes-1.pdf
Linux Notes-1.pdfLinux Notes-1.pdf
Linux Notes-1.pdfasif64436
 
Linux Command Suumary
Linux Command SuumaryLinux Command Suumary
Linux Command Suumarymentorsnet
 
Introduction to Unix-like systems (Part I-IV)
Introduction to Unix-like systems (Part I-IV)Introduction to Unix-like systems (Part I-IV)
Introduction to Unix-like systems (Part I-IV)hildenjohannes
 
Unix_commands_theory
Unix_commands_theoryUnix_commands_theory
Unix_commands_theoryNiti Patel
 
Chapter 2 Introduction to Unix Concepts
Chapter 2 Introduction to Unix ConceptsChapter 2 Introduction to Unix Concepts
Chapter 2 Introduction to Unix ConceptsMeenalJabde
 
Unix Shell Script - 2 Days Session.pptx
Unix Shell Script - 2 Days Session.pptxUnix Shell Script - 2 Days Session.pptx
Unix Shell Script - 2 Days Session.pptxRajesh Kumar
 
Raspberry Pi - Lecture 2 Linux OS
Raspberry Pi - Lecture 2 Linux OSRaspberry Pi - Lecture 2 Linux OS
Raspberry Pi - Lecture 2 Linux OSMohamed Abdallah
 
PowerPoint_merge.ppt on unix programming
PowerPoint_merge.ppt on unix programmingPowerPoint_merge.ppt on unix programming
PowerPoint_merge.ppt on unix programmingPriyadarshini648418
 

Ähnlich wie Introduction to Unix Operating System Utilities and Shell Programming (20)

cisco
ciscocisco
cisco
 
3. intro
3. intro3. intro
3. intro
 
Terminal basic-commands(Unix) -partI
Terminal basic-commands(Unix) -partITerminal basic-commands(Unix) -partI
Terminal basic-commands(Unix) -partI
 
Linux powerpoint
Linux powerpointLinux powerpoint
Linux powerpoint
 
Presentation for RHCE in linux
Presentation  for  RHCE in linux Presentation  for  RHCE in linux
Presentation for RHCE in linux
 
Introduction to Unix
Introduction to UnixIntroduction to Unix
Introduction to Unix
 
Shell & Shell Script
Shell & Shell ScriptShell & Shell Script
Shell & Shell Script
 
Shell & Shell Script
Shell & Shell Script Shell & Shell Script
Shell & Shell Script
 
unix.ppt
unix.pptunix.ppt
unix.ppt
 
Linux Notes-1.pdf
Linux Notes-1.pdfLinux Notes-1.pdf
Linux Notes-1.pdf
 
Linux Commands
Linux CommandsLinux Commands
Linux Commands
 
Linux Command Suumary
Linux Command SuumaryLinux Command Suumary
Linux Command Suumary
 
Introduction to Unix-like systems (Part I-IV)
Introduction to Unix-like systems (Part I-IV)Introduction to Unix-like systems (Part I-IV)
Introduction to Unix-like systems (Part I-IV)
 
Unix_commands_theory
Unix_commands_theoryUnix_commands_theory
Unix_commands_theory
 
Shell Scripting
Shell ScriptingShell Scripting
Shell Scripting
 
Chapter 2 Introduction to Unix Concepts
Chapter 2 Introduction to Unix ConceptsChapter 2 Introduction to Unix Concepts
Chapter 2 Introduction to Unix Concepts
 
Unix Shell Script - 2 Days Session.pptx
Unix Shell Script - 2 Days Session.pptxUnix Shell Script - 2 Days Session.pptx
Unix Shell Script - 2 Days Session.pptx
 
UNIX.pptx
UNIX.pptxUNIX.pptx
UNIX.pptx
 
Raspberry Pi - Lecture 2 Linux OS
Raspberry Pi - Lecture 2 Linux OSRaspberry Pi - Lecture 2 Linux OS
Raspberry Pi - Lecture 2 Linux OS
 
PowerPoint_merge.ppt on unix programming
PowerPoint_merge.ppt on unix programmingPowerPoint_merge.ppt on unix programming
PowerPoint_merge.ppt on unix programming
 

Kürzlich hochgeladen

The role of Geography in climate education: science and active citizenship
The role of Geography in climate education: science and active citizenshipThe role of Geography in climate education: science and active citizenship
The role of Geography in climate education: science and active citizenshipKarl Donert
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...Nguyen Thanh Tu Collection
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdfMr Bounab Samir
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfPrerana Jadhav
 
Indexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfIndexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfChristalin Nelson
 
Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWQuiz Club NITW
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxkarenfajardo43
 
Sulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesSulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesVijayaLaxmi84
 
Satirical Depths - A Study of Gabriel Okara's Poem - 'You Laughed and Laughed...
Satirical Depths - A Study of Gabriel Okara's Poem - 'You Laughed and Laughed...Satirical Depths - A Study of Gabriel Okara's Poem - 'You Laughed and Laughed...
Satirical Depths - A Study of Gabriel Okara's Poem - 'You Laughed and Laughed...HetalPathak10
 
DiskStorage_BasicFileStructuresandHashing.pdf
DiskStorage_BasicFileStructuresandHashing.pdfDiskStorage_BasicFileStructuresandHashing.pdf
DiskStorage_BasicFileStructuresandHashing.pdfChristalin Nelson
 
CHUYÊN ĐỀ ÔN THEO CÂU CHO HỌC SINH LỚP 12 ĐỂ ĐẠT ĐIỂM 5+ THI TỐT NGHIỆP THPT ...
CHUYÊN ĐỀ ÔN THEO CÂU CHO HỌC SINH LỚP 12 ĐỂ ĐẠT ĐIỂM 5+ THI TỐT NGHIỆP THPT ...CHUYÊN ĐỀ ÔN THEO CÂU CHO HỌC SINH LỚP 12 ĐỂ ĐẠT ĐIỂM 5+ THI TỐT NGHIỆP THPT ...
CHUYÊN ĐỀ ÔN THEO CÂU CHO HỌC SINH LỚP 12 ĐỂ ĐẠT ĐIỂM 5+ THI TỐT NGHIỆP THPT ...Nguyen Thanh Tu Collection
 
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptxMan or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptxDhatriParmar
 
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Association for Project Management
 
Comparative Literature in India by Amiya dev.pptx
Comparative Literature in India by Amiya dev.pptxComparative Literature in India by Amiya dev.pptx
Comparative Literature in India by Amiya dev.pptxAvaniJani1
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...Nguyen Thanh Tu Collection
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Projectjordimapav
 
6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroom6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroomSamsung Business USA
 
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...DhatriParmar
 

Kürzlich hochgeladen (20)

The role of Geography in climate education: science and active citizenship
The role of Geography in climate education: science and active citizenshipThe role of Geography in climate education: science and active citizenship
The role of Geography in climate education: science and active citizenship
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdf
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdf
 
Indexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfIndexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdf
 
Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITW
 
Spearman's correlation,Formula,Advantages,
Spearman's correlation,Formula,Advantages,Spearman's correlation,Formula,Advantages,
Spearman's correlation,Formula,Advantages,
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
 
Sulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesSulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their uses
 
Satirical Depths - A Study of Gabriel Okara's Poem - 'You Laughed and Laughed...
Satirical Depths - A Study of Gabriel Okara's Poem - 'You Laughed and Laughed...Satirical Depths - A Study of Gabriel Okara's Poem - 'You Laughed and Laughed...
Satirical Depths - A Study of Gabriel Okara's Poem - 'You Laughed and Laughed...
 
DiskStorage_BasicFileStructuresandHashing.pdf
DiskStorage_BasicFileStructuresandHashing.pdfDiskStorage_BasicFileStructuresandHashing.pdf
DiskStorage_BasicFileStructuresandHashing.pdf
 
Mattingly "AI & Prompt Design" - Introduction to Machine Learning"
Mattingly "AI & Prompt Design" - Introduction to Machine Learning"Mattingly "AI & Prompt Design" - Introduction to Machine Learning"
Mattingly "AI & Prompt Design" - Introduction to Machine Learning"
 
CHUYÊN ĐỀ ÔN THEO CÂU CHO HỌC SINH LỚP 12 ĐỂ ĐẠT ĐIỂM 5+ THI TỐT NGHIỆP THPT ...
CHUYÊN ĐỀ ÔN THEO CÂU CHO HỌC SINH LỚP 12 ĐỂ ĐẠT ĐIỂM 5+ THI TỐT NGHIỆP THPT ...CHUYÊN ĐỀ ÔN THEO CÂU CHO HỌC SINH LỚP 12 ĐỂ ĐẠT ĐIỂM 5+ THI TỐT NGHIỆP THPT ...
CHUYÊN ĐỀ ÔN THEO CÂU CHO HỌC SINH LỚP 12 ĐỂ ĐẠT ĐIỂM 5+ THI TỐT NGHIỆP THPT ...
 
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptxMan or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
 
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
 
Comparative Literature in India by Amiya dev.pptx
Comparative Literature in India by Amiya dev.pptxComparative Literature in India by Amiya dev.pptx
Comparative Literature in India by Amiya dev.pptx
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Project
 
6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroom6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroom
 
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
 

Introduction to Unix Operating System Utilities and Shell Programming

  • 1. Operating Systems Part II: Introduction to the Unix Operating System (Utilities and Shell Programming) 1
  • 2. Unix Design Principles  Time-sharing system  Supports multiple processes  Simplicity is key -> kernel provides small set of functionality  Source code provided with O/S  Designed by programmers for programmers (i.e. programmable shell, make, SCCS) 2
  • 3. Unix Design Principles  Unix later used for networking, graphics, real- time operation (not part of the original programming objective)  New functionality required large amount of code (networking, GUI doubled the size of the system)  Continued strength -> even with new development, system still remained Unix 3
  • 4. Programmer Interface (The users) shells and commands compilers and interpreters system libraries system interface to the kernel swapping demand paging disk and tape drivers virtual memory kernel file system page replacement CPU scheduling signals kernel interface to the hardware hardware 4
  • 5. The Unix Shell  Command interpreter – Most common user interface – Normally executes user-written and system programs – Called shell in Unix because it surrounds the kernel  In Unix, users can write their own shell 5
  • 6. The Unix Shell  Most popular Unix shells: – Bourne shell (Steve Bourne, prompt is ‘$’) – C shell (Bill Joy, most popular on BSD systems, prompt is ‘%’) – Korn shell (Dave Korn, became popular because it combines features of C and Bourne shells, prompt is ‘$’)  Unix GUIs: X, OpenView, Motif 6
  • 7. The Unix Shell  Users can create programs using shell scripts (equivalent to batch files in MS-DOS)  Most popular Unix shells are also programming languages complete with variables and control constructs (loops, conditional, etc.)  Shell programming can be used to create another shell 7
  • 8. Unix Commands  Commands all have the same structure  Case-sensitive! (cd <> CD, unlike in MS-DOS)  The number of commands kept small but each command is extended through options/switches (preceded by ‘-’) 8
  • 9. Unix Commands  Example – Basic directory command: ls (lists all contents of a directory) – Extended command: ls -l (lists contents plus other file information) 9
  • 10. The Unix File System  Features of the Unix File System – Hierarchical structure (similar to MS-DOS) – Files are expandable (may grow are required) – Security rights associated w/ each file/ directory  Incorporates three-tiered structure on file access  9 bits (User-Group-Others, rwxrwxrwx)  Access types (r - Read, w - Write, x - Execute, ‘-’ means no access) -rwx---r-x 1 aam faculty 37 May 06 7:35 test – Files may be shared (concurrent access) 10
  • 11. The Unix File System  Features of Unix File System (continued) – Various information kept for each file (i.e. name, location, size, owner, security, modified by, last access by, date & time stamp, etc.) – File links - mechanism that allows multiple file names to refer to the same data on the storage device 11
  • 12. The Unix File System  Most often used file system commands: – pwd (present working directory) – cd (change directory) – mkdir (create directory) – rmdir (remove directory) – ls (list directory contents) – cat (concatenate files) / more (pauses after screen is full) – cp (copy file) 12
  • 13. The Unix File System  Most often used file system commands: – vi (edit a file) – mv (move a file) – rm (remove file) – ln (create link) – chmod (change file access mode) – chown (change file owner -> can be done only by “root”/file owner – cmp / diff (compare 2 files) 13
  • 14. Shell Basics  Shell variables – Similar to environment variables in MS-DOS – Syntax: varname=value – Preceded by $ when printing value (e.g. echo $x, where x is a variable) – Special variable PS1 Variable that contains string for command line prompt May be replaced 14
  • 15. Shell Basics  Input/Output commands – read - get input from keyboard and assign it to a variable – echo - send stream of characters to screen – pr - send output to printer 15
  • 16. Shell Basics  Command substitution – The output is taken instead of the command itself – Command is enclosed in `` (e.g. x=`date`) – Common uses:  Variable assignment  Command line arguments 16
  • 17. Shell Basics  Wildcards ? Matches any single character except a leading ‘.’ (dot) * Matches zero or more characters except a leading dot [] Defines a class of characters - Defines an inclusive ranges (e.g. [0-9]) ! Negates the defined class 17
  • 18. Shell Basics  Quoting characters Developed because of certain characters have special meaning (e.g. $, *, <, >, #, etc.) Removes meaning of the next character ’ Removes meaning of all characters ” Removes meaning of all characters except , $, and ” 18
  • 19. Shell Basics  Exercise for quoting characters What’s the difference between... echo ’$abc’ echo ”$abc” echo $abc 19
  • 20. Shell Basics  Redirection Every time a shell is started, three files (devices) are automatically opened: – stdin (standard input) - device from w/c the program reads the input (keyboard), file descriptor 0 – stdout (standard output) - device to w/c the program writes the output (monitor), file descriptor 1 – stderr (standard error) - device to w/c the program writes the errors (monitor), file descriptor 2 20
  • 21. Shell Basics  Redirection (cont’d) – Redirection - output is written to or read from another file instead of the standard files/devices – Syntax: command symbol filename – Input redirection (<) - any command that reads its input from stdin can have it read from a file 21
  • 22. Shell Basics  Redirection (cont’d) – Output redirection (> or >>) - any command that writes its output to stdout can be redirected to create, overwrite, or append to another file – Error redirection (2> or 2>>) - error messages are redirected to create, overwrite, or append to another file 22
  • 23. Shell Basics  Redirection (cont’d) Special redirection commands: 2>&1 - redirects standard errors on same stream as stdout 1>&2 - redirects outputs to stdout on same stream as stderr 23
  • 24. Shell Basics  Piping – Sends output of one command as input of another command – Syntax: command1 | command2 – Eliminates temporary files using redirection commands, for example $ date > tmpfile $ wc tmpfile $ rm tmpfile Can be written instead as date | wc 24
  • 25. Shell Basics  Filters – Program that reads input, performs translation, produces output – Commonly used filters:  grep (looks for occurrences of words/phrases in files)  sort (sorts input and writes to the output)  sed (reads lines from input file, applies edit commands, and outputs to stdout) 25
  • 26. Shell Basics  Filters (cont’d) – Commonly used filters  awk – designed by Al Aho, Peter Weinberger, and Brian Kernighan – much more flexible and addresses limitations of sed – allows programming constructs to be used (looping, variables, arithmetic, etc.) – processing language based on C 26
  • 27. Shell Programming  Command line arguments – Shellscript command parameters are represented by $number – Number indicates position of command argument – Example: myprog word1 bin  $1 = word1  $2 = bin  $0 = myprog 27
  • 28. Shell Programming  Command line arguments – Other important shell variables related to command parameters $# the number of arguments $* all arguments 28
  • 29. Shell Programming  Decision statements – IF command if command then commands if condition is true else commands if condition is false fi 29
  • 30. Shell Programming  Decision statements – CASE command case word in pattern) commands;; pattern) commands;; ... esac 30
  • 31. Shell Programming  Looping constructs – FOR loop for var in list of words do loop body , $var set to successive elements of the list done 31
  • 32. Shell Programming  Looping constructs (cont’d) – WHILE loop while command do loop body executed as long as command is true done 32
  • 33. Shell Programming  Looping constructs (cont’d) – UNTIL loop until command do loop body executed as long as command is true done – The symbol ‘:’ is a shell built-in that does nothing but return true – The command true can also be used – ‘:’ is more efficient since it is not a command 33