************* BACK AND FORTH PAGING SUBROUTINE ************

PAGEFLOP

If they want to quit, do so
 If They want to quit subsession, Do SO!
  Decrement LOCAL and GLOBAL Page Counters

FORWARD

  Increment LOCAL and GLOBAL Page Counters
   *************** END PAGEFLOP *********************
  ****** CHAPTER INTERNAL SELECTOR ALGORITHM ******

SELECTOR

   Reset Local Page Counter

SELAGAIN

 CHECK IF ONLY A <CR>

WRONGSEL

YOUR SELECTION IS NOT IN THE 0 - #SELIMIT  RANGE  Please try again

SELRTRN

   <<<<< BORDER DRAWING SUBROUTINE FOR EXAMPLES >>>>>>>>

NEXT

 $V1$
 $V1$

P0

Copyright CourseWare Technologies Inc., 1985-88


Lesson - 5


 SYSTEM STARTUP AND SHUTDOWN 

MENU

Startup & Shutdown|Topics to Learn|5-0|10,50
     #                    Topic
    ---                  -------
     1    -     Powering Up and Booting the System
     2    -     Single-User Mode
     3    -     The init Process
     4    -     Multi-User Mode
     5    -     The Clock Daemon - cron
     6    -     The Shutdown Process
     7    -     Lesson Review
     0    -     Return to the Main Menu

P1

Startup & Shutdown|Booting Your System|5-1.1|5,50
     Because starting up and bringing down your 
UNIX system involves more than merely flipping 
the power switch or pulling the power cord, we 
hope that this lesson will clarify the powering 
up and shutting down procedures.

P2

Startup & Shutdown|Booting Your System|5-1.2|10,54
     We also wish to note that on many new UNIX 
systems the process of starting up the system has 
been greatly simplified, and most of the time only 
involves:
 
     *  connecting all of the components,
     *  turning all of the components on,
     *  checking the prompt,
     *  pressing the <CR> or the shift key, and 
     *  perhaps entering the current date.

P3

Startup & Shutdown|Powering Up Your System|5-1.3|9,54
     The first steps in starting up the UNIX system 
are connecting all the system components like the 
CPU, the Disk Drives, the console, terminals, etc.,
and turning on the power.


     The next step is to "boot" UNIX.   Booting is 
the process of loading the UNIX kernel into the 
system's memory.  The UNIX kernel size varies from 
CPU to CPU, but is around 100 kilobytes.

P4

Startup & Shutdown|Booting Your System|5-1.4|7,49
     After the power-up procedure, the system 
either will boot automatically or it will give 
you a prompt to which you usually only need to 
respond with a <CR> or by pressing the space bar.  
Unless a different response is specified, the 
system should start the UNIX booting process.
     After the power-up procedure, the system 
should boot automatically and give you a prompt like:

                 UNIX System V
                 Boot:


     You need to respond only with a <CR>.
Startup & Shutdown|Booting Your System|5-1.4|10,54
     After the power-up procedure, the system 
performs self-test routines followed by an auto-boot.  It 
finishes by displaying a line like the following one followed 
by a login prompt. 

UNIX 4.2 Release 3.4 (Name) Mon Nov 3 15:37:50 1988
login:


     Normally, no user intervention is required.

P5

Startup & Shutdown|Booting Your System|5-1.5|7,54
     If during the boot operation you get the message 
"UNIX not found", then you either made a mistake, or 
the UNIX boot block does not exist and needs to be 
created.  This means that at best you need to go through 
the routine system building procedure or at worst,
you have lost the root file system.
     If during the boot operation you get any of the 
following error messages:

          critical errors found
          no video board is found
          non-critical errors found

see the "Periodic Maintenance" section of your system 
administration manual.

P6

Startup & Shutdown|Booting Your System|5-1.6|11,50
     After the UNIX kernel is loaded into memory, 
two processes are started: 

     init    -  the system level/mode process 
                scheduler
     swapper -  swaps processes between primary memory 
                and disk.


We'll explain each of these in detail later.
     After the UNIX kernel is loaded into memory, several 
processes are started: 

    /etc/cron - executes commands at specified times 
    /etc/init - the system level/mode process scheduler
      swapper - swaps processes between primary memory and disk
         nfsd - starts daemons to handle client file system 
                requests (daemons are processes)
 /usr/lib/lpd - line printer spooling handler
  /usr/update - synchronizes the file system to allow recovery
                after a crash

We'll explain each of these in detail later.

P7

Startup & Shutdown|Single-User Mode|5-2.1|9,54
     In the process of loading the UNIX system, you 
may be asked whether you want to check the file system,
and if you respond affirmatively, the root file system 
will be checked.


     During the boot process, other messages may also 
appear on the console, such as the starting location
in main memory, the size of data areas, etc.

P8

Startup & Shutdown|Single-User Mode|5-2.2|9,46
     The UNIX Operating System then gives you 
copyright information.  For example:

    Copyright - 1987 - XYZ Systems of Unix_town
    XYX UNIX UTX - 32, Release 2.0 - May 1986
    Created Mon April 24    10:23:17 PDT 1985
    CTI Systems Corp. 
     The UNIX Operating System then gives you 
copyright information.  For example:

     Copyright Microsoft Corp. 1984
     Copyright Santa Cruz Operation Corp. 1985
     UNIX System V. Rel. 2.0
     Created Mon April 24    10:23:17 PDT 1985
     and YOUR system login prompt, eg:
     CTI386!login
     The UNIX System then gives you copyright 
information.  For example:

     Copyright  (c)  1986 by XXX Microsystems, Inc.
         .
         .
         .
     Automatic reboot in progress ...
     Mon Dec 28 16:47:56 PST 1988

P9

Startup & Shutdown|Single-User Mode|5-2.3|4,46
     At the point when only the system console 
processes and the processes init and swapper 
are running, the system is said to be in
single-user or maintenance mode. 

P10

Startup & Shutdown|Single-User Mode|5-2.4|8,54
     In single-user mode, the system console runs as
superuser, the system prompt is  # , and no other users 
can log in.  Note that the system administrator can 
set up the system so that it comes up automatically 
in multi-user mode.


     Because a password is not required to enter single-user 
mode during system power up, it is important that only 
trusted individuals be allowed into the machine room 
without supervision.

P11

Startup & Shutdown|The init Process|5-3.1|8,56
     One of the constantly running processes is init.  
This process does the UNIX system process control 
initialization.  It is invoked as the last step of
the boot procedure. 


     init begins by opening the console device, 
usually /dev/console, for reading and writing.  

P12

Startup & Shutdown|The init Process|5-3.2|8,56
     If you are in multi-user mode, init creates 
a login process for each terminal port, opening them 
for reading and writing.  It does this by performing 
the tasks designated in either the file /etc/rc, 
or /etc/rc.boot.


     On a UNIX system, the active ports are 
designated in the file /etc/ttys.
     On a UNIX system, the active ports are 
designated in the file /etc/ttys.
     On a UNIX system, the active ports are 
designated in the file /etc/inittab.

P13

Startup & Shutdown|The init Process|5-3.3|15,54
     The /etc/inittab file is read by the init program 
and specifies form which terminals users will be 
allowed to log on.  It's entries have the format:



 id      is the one or two character process id number
 level   is the level in which the process is to be run
 action  is one of 4: sysinit, wait, respawn, or off
 process is the executable UNIX program

Note: when changing levels, init kills all 
processes not specified for the new level.
     The /etc/ttys file is the UNIX terminal status 
file read by the init program.  It specifies from
which terminals users will be allowed to log on.  This 
file contains the following information for each 
possible terminal on the UNIX system. 

   *  state - 1 or 0, where "1" = login enabled
                            "0" = login disabled
   *  mode - indicates the telecommunication line speed, 
      and is the argument to the getty program
         3 = 1200 baud, 4 = 2400 baud, 6 = 9600 baud, etc.
   *  name - is the name of the special device file 
      associated with the terminal (the prefix /dev is
      not included in the name)
     The /etc/ttys file is the UNIX terminal status 
file read by the init program.  It specifies from which
terminals users will be allowed to log on.  This file 
contains the following information for each terminal:

  *  state - 1 or 0, where "1" = login enabled
                                   "0" = login disabled
  *  mode - indicates the telecommunication line speed, 
      and is the argument to the getty program  
        1 = 150 baud, 6 = 2400 baud, 2 = 9600 baud, etc.
   3. name - is the name of the special device file 
      associated with the terminal (the prefix /dev is
      not included in the name)

     You should modify this file only while the system 
is in the single-user mode.  

P14

Startup & Shutdown|Multi-User Mode|5-4.1|11,54
     Unless your UNIX system is specifically a 
single-user system, you can change the system mode
to multi-user either by logging out i.e., pressing 
<CONTROL-d>, or by typing init (for system init-
ialization).  


     The system initialization process looks for
a shell script in a file called /etc/rc.  The 
commands in this file initialize all ports 
designated as active in the /etc/ttys file.
Startup & Shutdown|Multi-User Mode|5-4.1|9,54
     Unless your UNIX system is specifically a single-user 
system, you can change the system mode to multi-user 
with the command init (for system initialization).


     The system initialization process looks for a shell
script in a file called /etc/rc.  The commands in 
this file initialize all ports designated as active in 
the /etc/inittab file.

P15

Startup & Shutdown|Multi-User Mode|5-4.2|11,50
  init 2


  init


     This will initiate several processes including 
the shell command files:

            /etc/bcheckrc
            /etc/brc
            /etc/rc

and initialize login ports by starting the getty 
process for each port specified at the end of the 
/etc/inittab file.
     The above action will initiate several 
processes as specified in the /etc/rc, the multi-user 
initialization command file, and finally initialize 
all the ports designated as active in the /etc/ttys 
file.
     This will initiate several processes including 
the shell command files:

            /etc/rc.boot,
            /etc/rc, and
            /etc/rc.local

as well as initialize login ports by starting the getty 
process for each port specified at the end of /etc/ttys.

P16

Startup & Shutdown|Multi-User Mode|5-4.3|13,58
     The multi-user initialization command files serve the 
following purposes:

/etc/bcheckrc is the block checking file.  It normally 
asks for the time and date and sets them accordingly.  
bcheckrc also asks whether you want file systems other 
than root checked, if you reply yes, it will run the 
fsck command.

/etc/brc is the bootrun command file whose sole purpose is
to remove the table of mounted file systems (/etc/mnttab).

/etc/rc is the principal multi-user initialization file.
Startup & Shutdown|Multi-User Mode|5-4.3|9,54
     The multi-user initialization command files serve 
the following purposes:

  /etc/rc.boot - checks the file system

       /etc/rc - begins multi-user operation

/etc/rc.local - performs any locally written 
                 modifications
Startup & Shutdown|Multi-User Mode|5-4.3|8,54
     As the last step in multi-user initialization, 
the UNIX system will ask you to verify the date and 
time and print the message that the clock daemon cron 
is being started.  Finally if you have not modified 
the system id, which is in the file /etc/systemid 
every active terminal will get a prompt:

 

P17

Startup & Shutdown|Multi-User Mode|5-4.4|13,54
     The /etc/rc file is the main multi-user 
initialization shell script, and it contains 
commands to:

       *  mount the file systems
       *  start the line printer daemon /usr/lib/lpsched
       *  start the error daemon
       *  mount the file systems
       *  start the line printer daemon
       *  start the clock daemon 
       *  preserve editor files
       *  clear the /tmp directory
       *  put up various system configuration messages
Startup & Shutdown|Multi-User Mode|5-4.4|11,54
     The /etc/rc files are the main multi-user
initialization shell scripts, and they contain 
commands to:

       *  start the error daemon
       *  mount the file systems
       *  start the line printer daemon
       *  start the clock daemon 
       *  preserve editor files
       *  clear the /tmp directory
       *  put up various system configuration messages
Startup & Shutdown|Multi-User Mode|5-4.4|12,54
     The /etc/rc file is the main multi-user
initialization shell script, and it contains commands to:

       *  start the error daemon 
       *  mount the file systems
       *  clear out the /tmp directory
       *  start the line printer daemon 
       *  start the clock daemon
       *  start the update daemon
       *  set environment variables
       *  set the date
       *  put up various system configuration messages

P18

Startup & Shutdown|The Clock Daemon|5-5.1|8,54
     The command cron is the UNIX system clock
daemon, which, like the processes swapper and init, 
runs continuously, but only in the multi-user mode.  


     The command /etc/cron checks the /usr/lib/crontab 
file every minute.  If it finds waiting or sleeping
processes, it will execute them.

P19

Startup & Shutdown|The Clock Daemon|5-5.2|14,56
     The /usr/lib/crontab file has the following format:

    min    hour    day    month   day-of-week   process 
    0-59   0-23    1-31   1-12        0-6       (name)

The numbers below min, hour, etc., give the valid range.
The entries are separated by blanks or tabs.

Note: an * means do it every time, for example:

        45   16   *   *   5   /usr/weekendwish

says, that every Friday at 4:45 PM, the /etc/weekendwish 
program is to be run.

P20

Startup & Shutdown|The Shutdown Process|5-6.1|5,54
The shutdown process involves:

   1.  Checking whether there are users on the system 
       and, if so, sending them the system shutdown 
       message by using the wall command.

P21

Startup & Shutdown|The Shutdown Process|5-6.2|9,54
The shutdown process continued:

   2.  Flushing the buffers to hard disk and updating 
       the super block, using the sync command.
   3.  Killing all outstanding user processes after a 
       reasonable grace period.
   4.  Unmounting the file systems.
   5.  Change the mode to single-user.
   6.  Removing system power.

P22

Startup & Shutdown|The Shutdown Process|5-6.3|10,48
     The UNIX system shutdown can be done auto-
matically using the program /etc/shutdown.  The
shutdown program will post the UNIX system
shutdown message and will perform the necessary 
sync's.


     You must be logged in as a superuser and 
be in the root directory / to execute the 
/etc/shutdown command.

P23

Startup & Shutdown|The Shutdown Process|5-6.4|3,50
     After shutdown displays single-user mode 
and a prompt, the power to the system may be 
turned off.
Startup & Shutdown|The Shutdown Process|5-6.4|8,50
     The shutdown command will bring the system
into single-user mode, following that the UNIX 
system will display a message like "** Normal 
System Shutdown**" and stop, at which point you 
may turn off the power.


     Other quick shutdown commands that you may find 
on UNIX systems include shutquick and haltsys.
     The shutdown command will notify users that
a system halt is about to occur, inhibits any more 
logins, executes a sync to write all information 
to disk, and brings the system to single-user mode.  
You will see a message every minute until shutdown 
time that looks like:
       ***System shutdown message from root***
       System going down in x seconds

P24

Startup & Shutdown|The Shutdown Process|5-6.5|11,54
     If you need to bring the system down quickly 
and unexpectedly, you can use /etc/halt.  This 
command writes out information to the disks and halts 
the processor with no warning and no delay.  It is
very impolite to users.  


     The /etc/fasthalt command is a shell script 
which halts UNIX without checking the file systems.  
It should be used with care because it does not 
check file system consistency.
Startup & Shutdown|The Shutdown Process|5-6.5|4,54
     The command killall is a procedure used by 
/etc/shutdown to kill all active processes not 
directly related to the shutdown procedure.  You 
can also use this command.

P25

Startup & Shutdown|The Shutdown Process|5-6.6|5,54
     When the system has been halted, you can reboot
it with the /etc/reboot program.  This program 
causes the disks to be sync'ed, the hardware clocks to 
be resynchronized, and disk checks to be performed.  If 
all succeeds without problems, the system is brought up 
multi-user.