linux - init (8)



NAME
       init, telinit - process control initialization


SYNOPSIS
       /sbin/init [ -t sec ] [ 0123456SsQq ]
       /sbin/telinit [ -t sec ] [ 0123456sSQqabc ]


DESCRIPTION
   Init
       Init  is the father of all processes.  Its primary role is
       to create processes from  a  script  stored  in  the  file
       /etc/inittab  (see  inittab(5)).   This  file  usually has
       entries which cause init to spawn gettys on each line that
       users  can  log in.  It also controls autonomous processes
       required by any particular system.

       A run level is a  software  configuration  of  the  system
       which  allows only a selected group of processes to exist.
       The processes spawned by init for each of these run levels
       are  defined in the /etc/inittab file.  Init can be in one
       of eight run levels, 0-6 and S or s.   The  run  level  is
       changed  by  having  a  privileged user run /sbin/telinit,
       which sends appropriate signals to init, telling it  which
       run level to change to.

       After init is invoked as the last step of the kernel boot-
       ing, it looks for the file /etc/inittab to see if there is
       an  entry of the type initdefault (see inittab(5)).  init-
       default determines the initial run level  of  the  system.
       If there is no such entry or no /etc/inittab at all, a run
       level has to be entered at the system console.

       Run level S or s bring the system to single user mode  and
       do  not  require  an  /etc/initttab  file.  In single user
       mode, /bin/sh is invoked on /dev/console.

       When entering single user mode, init reads  the  console's
       ioctl(2)  states  from  /etc/ioctl.save. If this file does
       not exist, init initializes the line at 9600 baud and with
       CLOCAL  settings.   When  init leaves single user mode, it
       stores the console's ioctl settings in this file so it can
       re-use them for the next single-user session.

       When  entering a multi user mode the first time, init per-
       forms the boot and bootwait entries to allow file  systems
       to  be  mounted before users can log in.  Then all entries
       matching the run level are processed.

       When starting a new process, init first looks if the  file
       /etc/initscript exists. If it does, it uses this script to
       start the process.

       these files exist.

       After it has spawned all of the processes specified,  init
       waits for one of its descendant processes to die, a power-
       fail signal, or until it is signaled by  /sbin/telinit  to
       change  the  system's  run  level.   When one of the above
       three conditions occurs, it re-examines  the  /etc/inittab
       file.   New entries can be added to this file at any time.
       However, init still waits for one of the above three  con-
       ditions   to  occur.   To  provide  for  an  instantaneous
       response, the Q or q command can wake up init to  re-exam-
       ine the /etc/inittab file.

       If  init  is not in single user mode and receives a power-
       fail signal, special powerfail entries are invoked.

       When init is requested to change the run level,  it  sends
       the warning signal SIGTERM to all processes that are unde-
       fined in the new run level.   It  then  waits  20  seconds
       before  forcibly  terminating these processes via the kill
       signal SIGKILL.  Note that init  assumes  that  all  these
       processes  (and their descendants) remain in the same pro-
       cess group which init originally created for them.  If any
       process  changes its process group affiliation it will not
       receive these signals.  Such processes need to  be  termi-
       nated separately.

   telinit
       /sbin/telinit  is  linked  to /sbin/init.  It takes a one-
       character argument and signals init to perform the  appro-
       priate  action.   The  following arguments serve as direc-
       tives to /sbin/telinit:

       0,1,2,3,4,5 or 6
              tell /sbin/init to  switch  to  the  specified  run
              level.

       a,b,c  tell  /sbin/init to process only those /etc/inittab
              file entries having run level a,b or c.

       Q or q tells /sbin/init  to  re-examine  the  /etc/inittab
              file.

       S or s tells /sbin/init to switch to single user mode.

       /sbin/telinit  can  also tell init how much time it should
       wait between sending processes the TERM and the KILL  sig-
       nal;  default this is 20 seconds, but it can be changed by
       the -t sec option.

       /sbin/telinit can be invoked only by users with  appropri-
       ate privileges.


RUNLEVELS
       Run  levels 0, 1 and 6 are reserved. Runlevel 0 is used to
       halt the system, runlevel 6 is used to reboot  the  system
       and  runlevel 1 is used to get the system down into single
       user mode. Runlevel S is not really ment to use  directly,
       but  more  for the scripts that are executed when entering
       runlevel 1.For more information on this, see the  manpages
       for shutdown(1) and inittab(5).


FILES
       /etc/inittab
       /etc/initscript
       /dev/console
       /etc/ioctl.save
       /var/run/utmp
       /var/log/wtmp
       /dev/initctl


ENVIRONMENT
       Init  sets the following environment variables for all its
       children:

       PATH   Defaults to /bin:/usr/bin:

       INIT_VERSION
              As the name says. Useful to determine if  a  script
              runs directly from init.

       RUNLEVEL
              The current system runlevel.

       PREVLEVEL
              The  previous  runlevel  (useful  after  a runlevel
              switch).


BOOTFLAGS
       It is possible to pass a number of flags to init from  the
       boot monitor (eg. LILO). Init accepts the following flags:

       S, single
            Single user mode boot. In this mode  /etc/inittab  is
            examined  and  the  bootup rc scripts are usually run
            before the single user mode shell is started.


       1-5  Runlevel to boot into.


       -b, emergency
            Boot directly into a single user shell  without  run-
            ning any other startup scripts.


CONFORMING TO
       Init  is  compatible  with  the  System  V  init. It works
       closely together  with  the  scripts  in  the  directories
       /etc/init.d and /etc/rc{runlevel}.d.  If your systems uses
       this convention, there should be  a  README  file  in  the
       directory /etc/init.d explaining how these scripts work.


WARNINGS
       Init  assumes  that processes and descendants of processes
       remain in the same process group which was originally cre-
       ated  for them.  If the processes change their group, init
       can't kill them and you may  end  up  with  two  processes
       reading from one terminal line.


DIAGNOSTICS
       If  /sbin/init finds that it is continuously respawning an
       entry more than 10 times in 2 minutes, it will assume that
       there is an error in the command string, generate an error
       message on the system console, and refuse to respawn  this
       entry  until either 5 minutes has elapsed or it receives a
       signal.  This prevents it from eating up system  resources
       when someone makes a typographical error in the /etc/init-
       tab file or the program for the entry is removed.


AUTHOR
       Miquel van Smoorenburg  (miquels@drinkel.ow.org),  initial
       manual   page   by   Michael  Haardt  (u31b3hs@pool.infor-
       matik.rwth-aachen.de).


SEE ALSO
       getty(1), login(1), sh(1), who(1),  shutdown(1),  kill(2),
       inittab(5), initscript(5), utmp(5)