]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - sbin/init/init.8
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / sbin / init / init.8
1 .\" Copyright (c) 1980, 1991, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" This code is derived from software contributed to Berkeley by
5 .\" Donn Seeley at Berkeley Software Design, Inc.
6 .\"
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
9 .\" are met:
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.
18 .\"
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
29 .\" SUCH DAMAGE.
30 .\"
31 .\"     @(#)init.8      8.3 (Berkeley) 4/18/94
32 .\" $FreeBSD$
33 .\"
34 .Dd March 14, 2012
35 .Dt INIT 8
36 .Os
37 .Sh NAME
38 .Nm init
39 .Nd process control initialization
40 .Sh SYNOPSIS
41 .Nm
42 .Nm
43 .Oo
44 .Cm 0 | 1 | 6 |
45 .Cm c | q
46 .Oc
47 .Sh DESCRIPTION
48 The
49 .Nm
50 utility
51 is the last stage of the boot process.
52 It normally runs the automatic reboot sequence as described in
53 .Xr rc 8 ,
54 and if this succeeds, begins multi-user operation.
55 If the reboot scripts fail,
56 .Nm
57 commences single-user operation by giving
58 the super-user a shell on the console.
59 The
60 .Nm
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).
68 This
69 causes
70 .Nm
71 to run the
72 .Pa /etc/rc
73 start up command file in fastboot mode (skipping disk checks).
74 .Pp
75 If the
76 .Em console
77 entry in the
78 .Xr ttys 5
79 file is marked
80 .Dq insecure ,
81 then
82 .Nm
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
86 .Em console
87 is marked as
88 .Dq secure .
89 .Pp
90 If the system security level (see
91 .Xr security 7 )
92 is initially nonzero, then
93 .Nm
94 leaves it unchanged.
95 Otherwise,
96 .Nm
97 raises the level to 1 before going multi-user for the first time.
98 Since the level cannot be reduced, it will be at least 1 for
99 subsequent operation, even on return to single-user.
100 If a level higher than 1 is desired while running multi-user,
101 it can be set before going multi-user, e.g., by the startup script
102 .Xr rc 8 ,
103 using
104 .Xr sysctl 8
105 to set the
106 .Va kern.securelevel
107 variable to the required security level.
108 .Pp
109 If
110 .Nm
111 is run in a jail, the security level of the
112 .Dq host system
113 will not be affected.
114 Part of the information set up in the kernel to support a jail
115 is a per-jail security level.
116 This allows running a higher security level inside of a jail
117 than that of the host system.
118 See
119 .Xr jail 8
120 for more information about jails.
121 .Pp
122 In multi-user operation,
123 .Nm
124 maintains
125 processes for the terminal ports found in the file
126 .Xr ttys 5 .
127 The
128 .Nm
129 utility reads this file and executes the command found in the second field,
130 unless the first field refers to a device in
131 .Pa /dev
132 which is not configured.
133 The first field is supplied as the final argument to the command.
134 This command is usually
135 .Xr getty 8 ;
136 .Nm getty
137 opens and initializes the tty line
138 and
139 executes the
140 .Xr login 1
141 program.
142 The
143 .Nm login
144 program, when a valid user logs in,
145 executes a shell for that user.
146 When this shell
147 dies, either because the user logged out
148 or an abnormal termination occurred (a signal),
149 the cycle is restarted by
150 executing a new
151 .Nm getty
152 for the line.
153 .Pp
154 The
155 .Nm
156 utility can also be used to keep arbitrary daemons running,
157 automatically restarting them if they die.
158 In this case, the first field in the
159 .Xr ttys 5
160 file must not reference the path to a configured device node
161 and will be passed to the daemon
162 as the final argument on its command line.
163 This is similar to the facility offered in the
164 .At V
165 .Pa /etc/inittab .
166 .Pp
167 Line status (on, off, secure, getty, or window information)
168 may be changed in the
169 .Xr ttys 5
170 file without a reboot by sending the signal
171 .Dv SIGHUP
172 to
173 .Nm
174 with the command
175 .Dq Li "kill -HUP 1" .
176 On receipt of this signal,
177 .Nm
178 re-reads the
179 .Xr ttys 5
180 file.
181 When a line is turned off in
182 .Xr ttys 5 ,
183 .Nm
184 will send a SIGHUP signal to the controlling process
185 for the session associated with the line.
186 For any lines that were previously turned off in the
187 .Xr ttys 5
188 file and are now on,
189 .Nm
190 executes the command specified in the second field.
191 If the command or window field for a line is changed,
192 the change takes effect at the end of the current
193 login session (e.g., the next time
194 .Nm
195 starts a process on the line).
196 If a line is commented out or deleted from
197 .Xr ttys 5 ,
198 .Nm
199 will not do anything at all to that line.
200 .Pp
201 The
202 .Nm
203 utility will terminate multi-user operations and resume single-user mode
204 if sent a terminate
205 .Pq Dv TERM
206 signal, for example,
207 .Dq Li "kill \-TERM 1" .
208 If there are processes outstanding that are deadlocked (because of
209 hardware or software failure),
210 .Nm
211 will not wait for them all to die (which might take forever), but
212 will time out after 30 seconds and print a warning message.
213 .Pp
214 The
215 .Nm
216 utility will cease creating new processes
217 and allow the system to slowly die away, if it is sent a terminal stop
218 .Pq Dv TSTP
219 signal, i.e.\&
220 .Dq Li "kill \-TSTP 1" .
221 A later hangup will resume full
222 multi-user operations, or a terminate will start a single-user shell.
223 This hook is used by
224 .Xr reboot 8
225 and
226 .Xr halt 8 .
227 .Pp
228 The
229 .Nm
230 utility will terminate all possible processes (again, it will not wait
231 for deadlocked processes) and reboot the machine if sent the interrupt
232 .Pq Dv INT
233 signal, i.e.\&
234 .Dq Li "kill \-INT 1".
235 This is useful for shutting the machine down cleanly from inside the kernel
236 or from X when the machine appears to be hung.
237 .Pp
238 The
239 .Nm
240 utility will do the same, except it will halt the machine if sent
241 the user defined signal 1
242 .Pq Dv USR1 ,
243 or will halt and turn the power off (if hardware permits) if sent
244 the user defined signal 2
245 .Pq Dv USR2 .
246 .Pp
247 When shutting down the machine,
248 .Nm
249 will try to run the
250 .Pa /etc/rc.shutdown
251 script.
252 This script can be used to cleanly terminate specific programs such
253 as
254 .Nm innd
255 (the InterNetNews server).
256 If this script does not terminate within 120 seconds,
257 .Nm
258 will terminate it.
259 The timeout can be configured via the
260 .Xr sysctl 8
261 variable
262 .Va kern.init_shutdown_timeout .
263 .Pp
264 The role of
265 .Nm
266 is so critical that if it dies, the system will reboot itself
267 automatically.
268 If, at bootstrap time, the
269 .Nm
270 process cannot be located, the system will panic with the message
271 .Dq "panic: init died (signal %d, exit %d)" .
272 .Pp
273 If run as a user process as shown in the second synopsis line,
274 .Nm
275 will emulate
276 .At V
277 behavior, i.e., super-user can specify the desired
278 .Em run-level
279 on a command line, and
280 .Nm
281 will signal the original
282 (PID 1)
283 .Nm
284 as follows:
285 .Bl -column Run-level SIGTERM
286 .It Sy "Run-level       Signal  Action"
287 .It Cm 0 Ta Dv SIGUSR2 Ta "Halt and turn the power off"
288 .It Cm 1 Ta Dv SIGTERM Ta "Go to single-user mode"
289 .It Cm 6 Ta Dv SIGINT Ta "Reboot the machine"
290 .It Cm c Ta Dv SIGTSTP Ta "Block further logins"
291 .It Cm q Ta Dv SIGHUP Ta Rescan the
292 .Xr ttys 5
293 file
294 .El
295 .Sh FILES
296 .Bl -tag -width /var/log/init.log -compact
297 .It Pa /dev/console
298 system console device
299 .It Pa /dev/tty*
300 terminal ports found in
301 .Xr ttys 5
302 .It Pa /etc/ttys
303 the terminal initialization information file
304 .It Pa /etc/rc
305 system startup commands
306 .It Pa /etc/rc.shutdown
307 system shutdown commands
308 .It Pa /var/log/init.log
309 log of
310 .Xr rc 8
311 output if the system console device is not available
312 .El
313 .Sh DIAGNOSTICS
314 .Bl -diag
315 .It "getty repeating too quickly on port %s, sleeping."
316 A process being started to service a line is exiting quickly
317 each time it is started.
318 This is often caused by a ringing or noisy terminal line.
319 .Bf -emphasis
320 Init will sleep for 30 seconds,
321 then continue trying to start the process.
322 .Ef
323 .It "some processes would not die; ps axl advised."
324 A process
325 is hung and could not be killed when the system was shutting down.
326 This condition is usually caused by a process
327 that is stuck in a device driver because of
328 a persistent device error condition.
329 .El
330 .Sh SEE ALSO
331 .Xr kill 1 ,
332 .Xr login 1 ,
333 .Xr sh 1 ,
334 .Xr ttys 5 ,
335 .Xr security 7 ,
336 .Xr getty 8 ,
337 .Xr halt 8 ,
338 .Xr jail 8 ,
339 .Xr rc 8 ,
340 .Xr reboot 8 ,
341 .Xr shutdown 8 ,
342 .Xr sysctl 8
343 .Sh HISTORY
344 An
345 .Nm
346 utility appeared in
347 .At v6 .
348 .Sh CAVEATS
349 Systems without
350 .Xr sysctl 8
351 behave as though they have security level \-1.
352 .Pp
353 Setting the security level above 1 too early in the boot sequence can
354 prevent
355 .Xr fsck 8
356 from repairing inconsistent file systems.
357 The
358 preferred location to set the security level is at the end of
359 .Pa /etc/rc
360 after all multi-user startup actions are complete.