1 .\" Copyright (c) 1980, 1991, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" This code is derived from software contributed to Berkeley by
5 .\" Donn Seeley at Berkeley Software Design, Inc.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\" notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\" notice, this list of conditions and the following disclaimer in the
14 .\" documentation and/or other materials provided with the distribution.
15 .\" 4. Neither the name of the University nor the names of its contributors
16 .\" may be used to endorse or promote products derived from this software
17 .\" without specific prior written permission.
19 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 .\" @(#)init.8 8.3 (Berkeley) 4/18/94
39 .Nd process control initialization
51 is the last stage of the boot process.
52 It normally runs the automatic reboot sequence as described in
54 and if this succeeds, begins multi-user operation.
55 If the reboot scripts fail,
57 commences single-user operation by giving
58 the super-user a shell on the console.
61 utility may be passed parameters
62 from the boot program to
63 prevent the system from going multi-user and to instead execute
64 a single-user shell without starting the normal daemons.
65 The system is then quiescent for maintenance work and may
66 later be made to go to multi-user by exiting the
67 single-user shell (with ^D).
73 start up command file in fastboot mode (skipping disk checks).
83 will require that the super-user password be
84 entered before the system will start a single-user shell.
85 The password check is skipped if the
89 Note that the password check does not protect from variables
99 If the system security level (see
101 is initially nonzero, then
106 raises the level to 1 before going multi-user for the first time.
107 Since the level cannot be reduced, it will be at least 1 for
108 subsequent operation, even on return to single-user.
109 If a level higher than 1 is desired while running multi-user,
110 it can be set before going multi-user, e.g., by the startup script
116 variable to the required security level.
120 is run in a jail, the security level of the
122 will not be affected.
123 Part of the information set up in the kernel to support a jail
124 is a per-jail security level.
125 This allows running a higher security level inside of a jail
126 than that of the host system.
129 for more information about jails.
131 In multi-user operation,
134 processes for the terminal ports found in the file
138 utility reads this file and executes the command found in the second field,
139 unless the first field refers to a device in
141 which is not configured.
142 The first field is supplied as the final argument to the command.
143 This command is usually
146 opens and initializes the tty line
153 program, when a valid user logs in,
154 executes a shell for that user.
156 dies, either because the user logged out
157 or an abnormal termination occurred (a signal),
158 the cycle is restarted by
165 utility can also be used to keep arbitrary daemons running,
166 automatically restarting them if they die.
167 In this case, the first field in the
169 file must not reference the path to a configured device node
170 and will be passed to the daemon
171 as the final argument on its command line.
172 This is similar to the facility offered in the
176 Line status (on, off, secure, getty, or window information)
177 may be changed in the
179 file without a reboot by sending the signal
184 .Dq Li "kill -HUP 1" .
185 On receipt of this signal,
190 When a line is turned off in
193 will send a SIGHUP signal to the controlling process
194 for the session associated with the line.
195 For any lines that were previously turned off in the
199 executes the command specified in the second field.
200 If the command or window field for a line is changed,
201 the change takes effect at the end of the current
202 login session (e.g., the next time
204 starts a process on the line).
205 If a line is commented out or deleted from
208 will not do anything at all to that line.
212 utility will terminate multi-user operations and resume single-user mode
216 .Dq Li "kill \-TERM 1" .
217 If there are processes outstanding that are deadlocked (because of
218 hardware or software failure),
220 will not wait for them all to die (which might take forever), but
221 will time out after 30 seconds and print a warning message.
225 utility will cease creating new processes
226 and allow the system to slowly die away, if it is sent a terminal stop
229 .Dq Li "kill \-TSTP 1" .
230 A later hangup will resume full
231 multi-user operations, or a terminate will start a single-user shell.
239 utility will terminate all possible processes (again, it will not wait
240 for deadlocked processes) and reboot the machine if sent the interrupt
243 .Dq Li "kill \-INT 1".
244 This is useful for shutting the machine down cleanly from inside the kernel
245 or from X when the machine appears to be hung.
249 utility will do the same, except it will halt the machine if sent
250 the user defined signal 1
252 or will halt and turn the power off (if hardware permits) if sent
253 the user defined signal 2
256 When shutting down the machine,
261 This script can be used to cleanly terminate specific programs such
264 (the InterNetNews server).
265 If this script does not terminate within 120 seconds,
268 The timeout can be configured via the
271 .Va kern.init_shutdown_timeout .
275 is so critical that if it dies, the system will reboot itself
277 If, at bootstrap time, the
279 process cannot be located, the system will panic with the message
280 .Dq "panic: init died (signal %d, exit %d)" .
282 If run as a user process as shown in the second synopsis line,
286 behavior, i.e., super-user can specify the desired
288 on a command line, and
290 will signal the original
294 .Bl -column Run-level SIGTERM
295 .It Sy "Run-level Signal Action"
296 .It Cm 0 Ta Dv SIGUSR1 Ta "Halt"
297 .It Cm 0 Ta Dv SIGUSR2 Ta "Halt and turn the power off"
298 .It Cm 1 Ta Dv SIGTERM Ta "Go to single-user mode"
299 .It Cm 6 Ta Dv SIGINT Ta "Reboot the machine"
300 .It Cm c Ta Dv SIGTSTP Ta "Block further logins"
301 .It Cm q Ta Dv SIGHUP Ta Rescan the
305 .Sh KERNEL ENVIRONMENT VARIABLES
308 variables are available as
311 .Bl -tag -width indent
313 If set to a valid directory in the root file system, it causes
317 operation on that directory, making it the new root directory.
318 That happens before entering single-user mode or multi-user
319 mode (but after executing the
322 This functionality has generally been eclipsed by rerooting.
328 If set to a valid file name in the root file system,
331 to directly execute that file as the very first action,
336 If set to a valid file name in the root file system,
339 to run that script as the very first action,
340 before doing anything else.
341 Signal handling and exit code interpretation is similar to
345 In particular, single-user operation is enforced
346 if the script terminates with a non-zero exit code,
347 or if a SIGTERM is delivered to the
350 This functionality has generally been eclipsed by rerooting.
356 Defines the shell binary to be used for executing the various shell scripts.
359 It is used for running the
363 if set, as well as for the
368 The value of the corresponding
370 variable is evaluated every time
372 calls a shell script, so it can be changed later on using the
375 In particular, if a non-default shell is used for running an
377 it might be desirable to have that script reset the value of
379 back to the default, so that the
381 script is executed with the standard shell
384 .Bl -tag -width /var/log/init.log -compact
386 system console device
388 terminal ports found in
391 the terminal initialization information file
393 system startup commands
394 .It Pa /etc/rc.shutdown
395 system shutdown commands
396 .It Pa /var/log/init.log
399 output if the system console device is not available
403 .It "getty repeating too quickly on port %s, sleeping."
404 A process being started to service a line is exiting quickly
405 each time it is started.
406 This is often caused by a ringing or noisy terminal line.
408 Init will sleep for 30 seconds,
409 then continue trying to start the process.
411 .It "some processes would not die; ps axl advised."
413 is hung and could not be killed when the system was shutting down.
414 This condition is usually caused by a process
415 that is stuck in a device driver because of
416 a persistent device error condition.
439 behave as though they have security level \-1.
441 Setting the security level above 1 too early in the boot sequence can
444 from repairing inconsistent file systems.
446 preferred location to set the security level is at the end of
448 after all multi-user startup actions are complete.