COMP 3000 2012 Week 3 Notes: Difference between revisions

From Soma-notes
Sdp (talk | contribs)
Added second lecture
 
(5 intermediate revisions by one other user not shown)
Line 45: Line 45:
** built on kernel functionality
** built on kernel functionality


== Why we're studying unix ==
== Why we're studying <span style="text-decoration:line-through;">unix</span> Linux based operating systems==
 
* all operating systems have roughly the same architecture
* windows is just a variation on unix. Built and designed very similarily.
* "Like a different accent. Same everything, but renamed"
* Slight differences in the way things are done
** Example: On Unix, configs reside in flat text files. In Windows, they live in an opaque key/value store called the registry.
 
Despite the similarities between OS families, Unix systems tend to be built much more transparently, which makes them a good vehicle to study OS topics


* all operating systems have basically the same architecture
* windows is just a variation on unix
* windows comes from vms
* windows comes from vms
** increment(vms) -> wnt
** increment(vms) -> wnt
see [http://www.team.net/mjb/hawg.html Unix - The Hole Hawg].


== Init and Shell Scripts ==
== Init and Shell Scripts ==
Line 61: Line 69:
** /etc/init.d/networking [start|stop]
** /etc/init.d/networking [start|stop]
** /etc/init.d/networking [start|stop]
** /etc/init.d/networking [start|stop]
'''Note:''' ''command'' [ ''keyword1'' | ''keyword2'' | ... ] means to execute a command with an optional choice of two or more keywords.
* shell scripts
* shell scripts
* start with
* start with
Line 67: Line 76:
** #!/bin/ksh
** #!/bin/ksh


Ann passes the lecture to Anil Somayaji
 
''Enter'' Anil Somayaji.
 
''[http://en.wikipedia.org/wiki/Exeunt Exeunt]'' Ann ''stage left''.
 


* Init scripts
* Init scripts
Line 76: Line 89:
* A file starting with #!
* A file starting with #!
** next comes the path to an interpreter for the rest of the file
** next comes the path to an interpreter for the rest of the file
* common directories
=== Common Directories ===
see [http://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard Filesystem Hierarchy Standard] and [http://www.pathname.com/fhs/pub/fhs-2.3.html FHS 2.3]
* /etc
* /etc
** pronounced ett-see
** pronounced ett-see
** configuration
** system wide configuration files
** different subdirectories
** different subdirectories and directory structures
** Competing Unix cultures apparent in the naming conventions and directory structures
** /etc/<prog>.conf
** /etc/<prog>.conf
** /etc/<prog>/[[User:Sdp|Sdp]]
** /etc/<prog>/
** /etc/<prog>.d/[[User:Sdp|Sdp]]
** /etc/<prog>.d/
* /bin
* /bin
** system binaries
** system binaries
** often this is local
** often this is local
** Bare minimum of what's needed to boot.
** Important for diskless systems (see /usr/) or think clients.
** Historically, we kept this as small as possible
* /lib
* /lib
** system libraries
** system libraries
Line 93: Line 111:
* /usr
* /usr
** often this is shared
** often this is shared
** Historically, the /usr/ directory was a remote file system mounted after the system had fully booted. Servers had more disk space than terminals/thin clients.
** /usr/bin
** /usr/bin
** user binaries
** user binaries
Line 111: Line 130:
* POSIX standard was an outcome of the fragmentation
* POSIX standard was an outcome of the fragmentation
* Free Software Foundation came out of the fragmentation
* Free Software Foundation came out of the fragmentation
** founded by rms (Richard M. Stallman)
** founded by rms ([http://xkcd.com/225/ Richard] M. [http://www.youtube.com/watch?v=1sxNy0qQDkU Stallman])
** not initially a very open development environment
** not initially a very open development environment
** built all the components of unix called GNU (GNU's Not Unix)
** built all the components of unix called GNU (GNU's Not Unix)

Latest revision as of 19:14, 30 September 2012

Shell

  • useful command line programs
    • bc -l
      • command line calculator
    • cal
      • command line calendar
    • uniq
      • filters out duplicate lines
    • sort
      • takes input on STDIN, sorts lines, prints to STDOUT
  • vmlinux is the linux kernel with virtual memory [vmlinux]
    • vmlinuz is the same but compressed
  • bash runs on vmlinux
    • most programs run on bash
    • ls/cd also run on vmlinux
    • ls runs as a child process of bash
  • to get rid of a misbehaving child
    • the parent must kill it
    • waits for child to die
    • an unreaped child becomes a zombie
    • zombies can't be killed, must be reaped
    • to kill a zombie, must kill parent
    • orphans become a child of init (ward of state)
    • init is good at reaping children

job control

  • job is a process
    • term comes from batch processing
  • Useful control sequences
    • Ctrl-C
      • terminate job
    • Ctrl-Z
      • stop job
  • To start a stopped job in the foreground
    • fg %n
      • where n is the job number
  • To start a stopped job in the background
    • bg %n
  • To determine jobs that are running
    • jobs
  • Who manages jobs?
    • the shell
    • built on kernel functionality

Why we're studying unix Linux based operating systems

  • all operating systems have roughly the same architecture
  • windows is just a variation on unix. Built and designed very similarily.
  • "Like a different accent. Same everything, but renamed"
  • Slight differences in the way things are done
    • Example: On Unix, configs reside in flat text files. In Windows, they live in an opaque key/value store called the registry.

Despite the similarities between OS families, Unix systems tend to be built much more transparently, which makes them a good vehicle to study OS topics

  • windows comes from vms
    • increment(vms) -> wnt

see Unix - The Hole Hawg.

Init and Shell Scripts

Guest mini-lecture by Ann Fry

  • /etc/init.d/
  • initialization scripts
  • examples
    • /etc/init.d/networking [start|stop]
    • /etc/init.d/networking [start|stop]

Note: command [ keyword1 | keyword2 | ... ] means to execute a command with an optional choice of two or more keywords.

  • shell scripts
  • start with
    • #!/bin/bash
    • #!/bin/csh
    • #!/bin/ksh


Enter Anil Somayaji.

Exeunt Ann stage left.


  • Init scripts
  • Traditional init scripts run sequentially
  • Modern init scripts run in parallel
  • executables
  • ELF
  • A file starting with #!
    • next comes the path to an interpreter for the rest of the file

Common Directories

see Filesystem Hierarchy Standard and FHS 2.3

  • /etc
    • pronounced ett-see
    • system wide configuration files
    • different subdirectories and directory structures
    • Competing Unix cultures apparent in the naming conventions and directory structures
    • /etc/<prog>.conf
    • /etc/<prog>/
    • /etc/<prog>.d/
  • /bin
    • system binaries
    • often this is local
    • Bare minimum of what's needed to boot.
    • Important for diskless systems (see /usr/) or think clients.
    • Historically, we kept this as small as possible
  • /lib
    • system libraries
  • /home
    • user directories
  • /usr
    • often this is shared
    • Historically, the /usr/ directory was a remote file system mounted after the system had fully booted. Servers had more disk space than terminals/thin clients.
    • /usr/bin
    • user binaries
    • /usr/lib
    • user libraries

History of Unix

  • In the beginning, there was AT&T's Unix
  • AT&T gave site licenses with all the source
  • Berkeley developed networking (at least TCP/IP) called BSD
    • licensed under permissive BSD license
  • AT&T forked System V
    • Not permissively licensed
  • Sun created hardware to run unix and forked SunOS from BSD
  • Sun changed from SunOS (BSD) to Solaris (System V)
    • people disliked this
  • POSIX standard was an outcome of the fragmentation
  • Free Software Foundation came out of the fragmentation
    • founded by rms (Richard M. Stallman)
    • not initially a very open development environment
    • built all the components of unix called GNU (GNU's Not Unix)
    • yacc -> bison
    • more -> less
    • cc -> gcc
  • Anil was sysadmin for a crystalography lab
    • SGI IRX boxes
    • ran IRIX
  • 80386 came out
    • capable of running a real unix because of virtual memory
    • legal status of BSD kernel became an issue because of lawsuit
    • GNU started Hurd
    • Linus Torvalds writes Linux kernel
    • uses GNU license
    • allowed everyone to make contributions
  • Eventually BSD legal stuff got figured out
    • 386BSD
    • FreeBSD
    • NetBSD
      • OpenBSD
  • Anil's opinion
  • Linux has the best driver support of any OS including Windows

Back to Init

  • Why do we care?
  • Unix is a culture
  • the culture shows up all over, like in /etc, /etc/init.d
  • Now there are 3 major replacements for system V init scripts
  • system V init scripts are just shell scripts run sequentially
  • it's desirable to run the initialization in parallel
    • oh noes, race conditions
    • init scripts have dependencies!!
  • init scripts were ordered by convention
    • had to figure out all the dependencies
    • still not completely figured out
  • everything on linux is an open source project
  • look around for a good project to document


References

^ : https://en.wikipedia.org/wiki/Vmlinux