1INIT(8)               Linux System Administrator's Manual              INIT(8)
2
3
4

NAME

6       init, telinit - process control initialization
7

SYNOPSIS

9       /sbin/init [ -a ] [ -s ] [ -b ] [ -z xxx ] [ 0123456Ss ]
10       /sbin/telinit [ -t sec ] [ 0123456sSQqabcUu ]
11

DESCRIPTION

13   Init
14       Init  is  the  parent  of all processes.  Its primary role is to create
15       processes from a script stored in  the  file  /etc/inittab  (see  init‐
16       tab(5)).   This file usually has entries which cause init to spawn get‐
17       tys on each line that users can log in.  It  also  controls  autonomous
18       processes required by any particular system.
19

RUNLEVELS

21       A  runlevel is a software configuration of the system which allows only
22       a selected group of processes to exist.  The processes spawned by  init
23       for each of these runlevels are defined in the /etc/inittab file.  Init
24       can be in one of eight runlevels: 0–6 and S  or  s.   The  runlevel  is
25       changed  by having a privileged user run telinit, which sends appropri‐
26       ate signals to init, telling it which runlevel to change to.
27
28       Runlevels 0, 1, and 6 are reserved. Runlevel 0 is used to halt the sys‐
29       tem, runlevel 6 is used to reboot the system, and runlevel 1 is used to
30       get the system down into single user mode. Runlevel  S  is  not  really
31       meant  to  be used directly, but more for the scripts that are executed
32       when entering runlevel 1. For more information on this,  see  the  man‐
33       pages for shutdown(8) and inittab(5).
34
35       Runlevels  7-9  are  also  valid, though not really documented. This is
36       because "traditional" Unix variants don't use  them.   In  case  you're
37       curious,  runlevels  S and s are in fact the same.  Internally they are
38       aliases for the same runlevel.
39

BOOTING

41       After init is invoked as the last step of the kernel boot sequence,  it
42       looks for the file /etc/inittab to see if there is an entry of the type
43       initdefault (see inittab(5)). The initdefault entry determines the ini‐
44       tial  runlevel  of  the  system.   If  there  is  no  such entry (or no
45       /etc/inittab at all), a runlevel must be entered at the system console.
46
47       Runlevel S or s bring the system to single user mode and do not require
48       an  /etc/inittab  file.  In single user mode, a root shell is opened on
49       /dev/console.
50
51       When entering single user mode, init initializes the consoles stty set‐
52       tings  to sane values. Clocal mode is set. Hardware speed and handshak‐
53       ing are not changed.
54
55       When entering a multi-user mode for the first time, init  performs  the
56       boot  and  bootwait  entries to allow file systems to be mounted before
57       users can log in.  Then all entries  matching  the  runlevel  are  pro‐
58       cessed.
59
60       When  starting  a  new  process,  init  first  checks  whether the file
61       /etc/initscript exists. If it does, it uses this script  to  start  the
62       process.
63
64       Each  time  a child terminates, init records the fact and the reason it
65       died in /var/run/utmp and  /var/log/wtmp,  provided  that  these  files
66       exist.
67

CHANGING RUNLEVELS

69       After it has spawned all of the processes specified, init waits for one
70       of its descendant processes to die, a powerfail signal, or until it  is
71       signaled  by  telinit to change the system's runlevel.  When one of the
72       above three conditions occurs, it re-examines  the  /etc/inittab  file.
73       New entries can be added to this file at any time.  However, init still
74       waits for one of the above three conditions to occur.  To  provide  for
75       an  instantaneous response, the telinit Q or q command can wake up init
76       to re-examine the /etc/inittab file.
77
78       If init is not in single user mode  and  receives  a  powerfail  signal
79       (SIGPWR),  it reads the file /etc/powerstatus. It then starts a command
80       based on the contents of this file:
81
82       F(AIL) Power is failing, UPS is providing the power. Execute the power‐
83              wait and powerfail entries.
84
85       O(K)   The power has been restored, execute the powerokwait entries.
86
87       L(OW)  The  power is failing and the UPS has a low battery. Execute the
88              powerfailnow entries.
89
90       If /etc/powerstatus doesn't exist or contains anything  else  then  the
91       letters F, O or L, init will behave as if it has read the letter F.
92
93       Usage of SIGPWR and /etc/powerstatus is discouraged. Someone wanting to
94       interact with init should use the /dev/initctl control  channel  -  see
95       the  source  code  of the sysvinit package for more documentation about
96       this.
97
98       When init is requested to change the runlevel,  it  sends  the  warning
99       signal SIGTERM to all processes that are undefined in the new runlevel.
100       It then waits 5 seconds before forcibly terminating these processes via
101       the  SIGKILL  signal.   Note that init assumes that all these processes
102       (and their descendants) remain in the same  process  group  which  init
103       originally  created for them.  If any process changes its process group
104       affiliation it will not receive these signals.  Such processes need  to
105       be terminated separately.
106

TELINIT

108       /sbin/telinit  is linked to /sbin/init.  It takes a one-character argu‐
109       ment and signals init to perform the appropriate action.  The following
110       arguments serve as directives to telinit:
111
112       0,1,2,3,4,5 or 6
113              tell init to switch to the specified run level.
114
115       a,b,c  tell init to process only those /etc/inittab file entries having
116              runlevel a,b or c.
117
118       Q or q tell init to re-examine the /etc/inittab file.
119
120       S or s tell init to switch to single user mode.
121
122       U or u tell init to re-execute itself (preserving the  state).  No  re-
123              examining  of /etc/inittab file happens. Run level should be one
124              of Ss12345, otherwise request would be silently ignored.
125
126       telinit can also tell init how long it should wait between sending pro‐
127       cesses  the SIGTERM and SIGKILL signals.  The default is 5 seconds, but
128       this can be changed with the -t sec option.
129
130       telinit can be invoked only by users with appropriate privileges.
131
132       The init binary checks if it is init  or  telinit  by  looking  at  its
133       process  id; the real init's process id is always 1.  From this it fol‐
134       lows that instead of calling telinit one can also just use init instead
135       as a shortcut.
136

ENVIRONMENT

138       Init sets the following environment variables for all its children:
139
140       PATH   /bin:/usr/bin:/sbin:/usr/sbin
141
142       INIT_VERSION
143              As  the name says. Useful to determine if a script runs directly
144              from init.
145
146       RUNLEVEL
147              The current system runlevel.
148
149       PREVLEVEL
150              The previous runlevel (useful after a runlevel switch).
151
152       CONSOLE
153              The system console. This is really inherited  from  the  kernel;
154              however  if  it  is  not set init will set it to /dev/console by
155              default.
156

BOOTFLAGS

158       It is possible to pass a number of flags to init from the boot  monitor
159       (eg. LILO). Init accepts the following flags:
160
161       -s, S, single
162            Single  user  mode boot. In this mode /etc/inittab is examined and
163            the bootup rc scripts are usually run before the single user  mode
164            shell is started.
165
166       1-5  Runlevel to boot into.
167
168       -b, emergency
169            Boot  directly  into a single user shell without running any other
170            startup scripts.
171
172       -a, auto
173            The LILO boot loader adds the word "auto" to the command  line  if
174            it  booted  the kernel with the default command line (without user
175            intervention).  If this is found init sets the "AUTOBOOT" environ‐
176            ment  variable  to  "yes".  Note  that you cannot use this for any
177            security measures - of course the user could specify "auto" or  -a
178            on the command line manually.
179
180       -z xxx
181            The argument to -z is ignored. You can use this to expand the com‐
182            mand line a bit, so that it takes some more space  on  the  stack.
183            Init  can then manipulate the command line so that ps(1) shows the
184            current runlevel.
185

INTERFACE

187       Init listens on a fifo in /dev, /dev/initctl,  for  messages.   Telinit
188       uses this to communicate with init. The interface is not very well doc‐
189       umented or finished. Those interested should study the  initreq.h  file
190       in the src/ subdirectory of the init source code tar archive.
191

SIGNALS

193       Init reacts to several signals:
194
195       SIGHUP
196            Has the same effect as telinit q.
197
198       SIGUSR1
199            On  receipt  of this signals, init closes and re-opens its control
200            fifo, /dev/initctl. Useful for bootscripts when /dev is remounted.
201
202       SIGINT
203            Normally the kernel sends this signal to init when CTRL-ALT-DEL is
204            pressed. It activates the ctrlaltdel action.
205
206       SIGWINCH
207            The  kernel  sends this signal when the KeyboardSignal key is hit.
208            It activates the kbrequest action.
209
210

CONFORMING TO

212       Init is compatible with the System V init. It  works  closely  together
213       with  the  scripts  in  the  directories  /etc/init.d  and /etc/rc{run‐
214       level}.d.  If your system uses  this  convention,  there  should  be  a
215       README  file  in the directory /etc/init.d explaining how these scripts
216       work.
217

FILES

219       /etc/inittab
220       /etc/initscript
221       /dev/console
222       /var/run/utmp
223       /var/log/wtmp
224       /dev/initctl
225

WARNINGS

227       Init assumes that processes and descendants of processes remain in  the
228       same  process group which was originally created for them.  If the pro‐
229       cesses change their group, init can't kill them and you may end up with
230       two processes reading from one terminal line.
231

DIAGNOSTICS

233       If  init finds that it is continuously respawning an entry more than 10
234       times in 2 minutes, it will assume that there is an error in  the  com‐
235       mand  string,  generate  an  error  message  on the system console, and
236       refuse to respawn this entry until either 5 minutes has elapsed  or  it
237       receives  a  signal.   This prevents it from eating up system resources
238       when someone makes a typographical error in the  /etc/inittab  file  or
239       the program for the entry is removed.
240

AUTHOR

242       Miquel  van  Smoorenburg  (miquels@cistron.nl),  initial manual page by
243       Michael Haardt (u31b3hs@pool.informatik.rwth-aachen.de).
244

SEE ALSO

246       getty(1), login(1), sh(1),  runlevel(8),  shutdown(8),  kill(1),  init‐
247       tab(5), initscript(5), utmp(5)
248
249
250
251                                  29 Jul 2004                          INIT(8)
Impressum