root's shell games lecture in color

The root shell

Objectives

Summary of major differences: csh vs. sh

 topic         csh                     sh
 variables     set var=value           var=value
 environment   setenv VAR value        export VAR=value
 arrays        $a[1-9]                 no concept of array
 command exec  `command`               $(command)
 arithmetic    @ i = $i+$j             i=$[$i+$j]
 conditionals  if (conditions) then    if conditions; then 
                 ...                     ...
               else                    else
                 ...                     ...
               endif                   fi
 foreach       foreach i (stuff)       for i in stuff; do 
                 ...                     ...
               end                     done
 while         while (conditions)      while conditions; do 
                 ...                     ...
               end                     done
 exit status   $status                 $? 
 stderr        foo >& bar              foo > bar 2>&1
               foo >>& bar             foo >> bar 2>&1
               foo |& bar              foo | bar 2>&1
 startup       .cshrc                  .profile
 aliases       alias m more            no concept of alias

Summary of major similarities:

Subshells

Variables

Basic sh syntax:

Real difference between sh and csh:

Exit status

Obtaining exit status:

New command connectives:

Problem of the day #1:

Problem of the day #2

Using test

Input/Output redirection

File descriptors

Open file weirdnesses:

Things to remember while writing conditionals in sh

If statement

One caveat: words in tests can't be empty

Iteration

Substitutions

Some really powerful variable substitutions:

Problem of the day #3

Why sh?

System modes (run levels)

Boot and shutdown

Bootstrapping

Bootstrap Sequence

rc.sysinit- get system ready for single-user mode.

Now the real action starts

The great dance:

Why so much trouble?

Anatomy of a startup script

Example: /etc/rc.d/init.d/network

Checking whether init scripts are used

General Trends in Startup Scripts

Reading Startup Scripts

Overview


lecture in color

/comp/150NET/notes/sh.php
downloaded on Nov-23-2009 03:07:32 PM,
was last modified on Feb-17-2004 10:49:54 PM.

All lecture note content is copyright 2004 by
Alva L. Couch, Computer Science, Tufts University