• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Operating system (remuel)
 

Operating system (remuel)

on

  • 641 views

introduction to operating system

introduction to operating system

Statistics

Views

Total Views
641
Views on SlideShare
640
Embed Views
1

Actions

Likes
1
Downloads
18
Comments
0

1 Embed 1

http://www.docshut.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Operating system (remuel) Operating system (remuel) Presentation Transcript

    • 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 Unix3
    • 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 hardware4
    • 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 shell5
    • 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, Motif6
    • 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 shell7
    • 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 device11
    • 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 replaced14
    • 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 printer15
    • 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 arguments16
    • 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 class17
    • 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 $abc19
    • 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 220
    • 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 file21
    • 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 file22
    • 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 stderr23
    • 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 | wc24
    • 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 C26
    • 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 = myprog27
    • Shell Programming  Command line arguments – Other important shell variables related to command parameters $# the number of arguments $* all arguments28
    • Shell Programming  Decision statements – IF command if command then commands if condition is true else commands if condition is false fi29
    • Shell Programming  Decision statements – CASE command case word in pattern) commands;; pattern) commands;; ... esac30
    • Shell Programming  Looping constructs – FOR loop for var in list of words do loop body , $var set to successive elements of the list done31
    • Shell Programming  Looping constructs (cont’d) – WHILE loop while command do loop body executed as long as command is true done32
    • 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 command33