COMP 3000 2012 Week 3 Notes
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
- bc -l
- 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
- Ctrl-C
- To start a stopped job in the foreground
- fg %n
- where n is the job number
- fg %n
- 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
- 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