xref: /freebsd/sbin/init/init.8 (revision 380a989b3223d455375b4fae70fd0b9bdd43bafb)
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.\" 3. All advertising materials mentioning features or use of this software
16.\"    must display the following acknowledgement:
17.\"	This product includes software developed by the University of
18.\"	California, Berkeley and its contributors.
19.\" 4. Neither the name of the University nor the names of its contributors
20.\"    may be used to endorse or promote products derived from this software
21.\"    without specific prior written permission.
22.\"
23.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33.\" SUCH DAMAGE.
34.\"
35.\"     @(#)init.8	8.3 (Berkeley) 4/18/94
36.\"	$Id: init.8,v 1.12 1998/07/06 06:56:07 charnier Exp $
37.\"
38.Dd April 18, 1994
39.Dt INIT 8
40.Os BSD 4
41.Sh NAME
42.Nm init
43.Nd process control initialization
44.Sh SYNOPSIS
45.Nm init
46.Sh DESCRIPTION
47The
48.Nm
49program
50is the last stage of the boot process.
51It normally runs the automatic reboot sequence as described in
52.Xr reboot 8 ,
53and if this succeeds, begins multi-user operation.
54If the reboot scripts fail,
55.Nm
56commences single user operation by giving
57the super-user a shell on the console.
58The
59.Nm
60program may be passed parameters
61from the boot program to
62prevent the system from going multi-user and to instead execute
63a single user shell without starting the normal daemons.
64The system is then quiescent for maintenance work and may
65later be made to go to multi-user by exiting the
66single-user shell (with ^D).
67This
68causes
69.Nm
70to run the
71.Pa /etc/rc
72start up command file in fastboot mode (skipping disk checks).
73.Pp
74If the
75.Em console
76entry in the
77.Xr ttys 5
78file is marked ``insecure'',
79then
80.Nm
81will require that the superuser password be
82entered before the system will start a single-user shell.
83The password check is skipped if the
84.Em console
85is marked as ``secure''.
86.Pp
87The kernel runs with four different levels of security.
88Any superuser process can raise the security level, but only
89.Nm
90can lower it.
91The security levels are:
92.Bl -tag -width flag
93.It Ic -1
94Permanently insecure mode \- always run the system in level 0 mode.
95This is the default initial value.
96.It Ic 0
97Insecure mode \- immutable and append-only flags may be turned off.
98All devices may be read or written subject to their permissions.
99.It Ic 1
100Secure mode \- the system immutable and system append-only flags may not
101be turned off;
102disks for mounted filesystems,
103.Pa /dev/mem ,
104and
105.Pa /dev/kmem
106may not be opened for writing.
107.It Ic 2
108Highly secure mode \- same as secure mode, plus disks may not be
109opened for writing (except by
110.Xr mount 2 )
111whether mounted or not.
112This level precludes tampering with filesystems by unmounting them,
113but also inhibits running
114.Xr newfs 8
115while the system is multi-user.
116.It Ic 3
117Network secure mode \- same as highly secure mode, plus
118IP packet filter rules (see
119.Xr ipfw 8
120and
121.Xr ipfirewall 4 )
122can not be changed and dummynet configuration can not be adjusted.
123.El
124.Pp
125If the security level is initially -1, then
126.Nm
127leaves it unchanged.
128Otherwise,
129.Nm
130arranges to run the system in level 0 mode while single user
131and in level 1 mode while multiuser.
132If level 2 mode is desired while running multiuser,
133it can be set while single user, e.g., in the startup script
134.Pa /etc/rc ,
135using
136.Xr sysctl 8
137to set the
138.Dq kern.securelevel
139variable to the required security level.
140.Pp
141In multi-user operation,
142.Nm
143maintains
144processes for the terminal ports found in the file
145.Xr ttys 5 .
146.Nm Init
147reads this file, and executes the command found in the second field.
148This command is usually
149.Xr getty 8 ;
150.Nm getty
151opens and initializes the tty line
152and
153executes the
154.Xr login 1
155program.
156The
157.Nm login
158program, when a valid user logs in,
159executes a shell for that user.  When this shell
160dies, either because the user logged out
161or an abnormal termination occurred (a signal),
162the
163.Nm
164program wakes up, deletes the user
165from the
166.Xr utmp 5
167file of current users and records the logout in the
168.Xr wtmp 5
169file.
170The cycle is
171then restarted by
172.Nm
173executing a new
174.Nm getty
175for the line.
176.Pp
177Line status (on, off, secure, getty, or window information)
178may be changed in the
179.Xr ttys 5
180file without a reboot by sending the signal
181.Dv SIGHUP
182to
183.Nm
184with the command
185.Dq Li "kill -HUP 1" .
186On receipt of this signal,
187.Nm
188re-reads the
189.Xr ttys 5
190file.
191When a line is turned off in
192.Xr ttys 5 ,
193.Nm
194will send a SIGHUP signal to the controlling process
195for the session associated with the line.
196For any lines that were previously turned off in the
197.Xr ttys 5
198file and are now on,
199.Nm
200executes a new
201.Nm getty
202to enable a new login.
203If the getty or window field for a line is changed,
204the change takes effect at the end of the current
205login session (e.g., the next time
206.Nm
207starts a process on the line).
208If a line is commented out or deleted from
209.Xr ttys 5 ,
210.Nm
211will not do anything at all to that line.
212However, it will complain that the relationship between lines
213in the
214.Xr ttys 5
215file and records in the
216.Xr utmp 5
217file is out of sync,
218so this practice is not recommended.
219.Pp
220.Nm Init
221will terminate multi-user operations and resume single-user mode
222if sent a terminate
223.Pq Dv TERM
224signal, for example,
225.Dq Li "kill \-TERM 1" .
226If there are processes outstanding that are deadlocked (because of
227hardware or software failure),
228.Nm
229will not wait for them all to die (which might take forever), but
230will time out after 30 seconds and print a warning message.
231.Pp
232.Nm Init
233will cease creating new
234.Nm getty Ns 's
235and allow the system to slowly die away, if it is sent a terminal stop
236.Pq Dv TSTP
237signal, i.e.
238.Dq Li "kill \-TSTP 1" .
239A later hangup will resume full
240multi-user operations, or a terminate will start a single user shell.
241This hook is used by
242.Xr reboot 8
243and
244.Xr halt 8 .
245.Pp
246.Nm Init
247will terminate all possible processes (again, it will not wait
248for deadlocked processes) and reboot the machine if sent the interrupt
249.Pq Dv INT
250signal, i.e.
251.Dq Li "kill \-INT 1".
252This is useful for shutting the machine down cleanly from inside the kernel
253or from X when the machine appears to be hung.
254.Pp
255When shutting down the machine,
256.Nm
257will try to run the
258.Pa /etc/rc.shutdown
259script. This script can be used to cleanly terminate specific programs such
260as
261.Nm innd
262(the InterNetNews server).
263.Pp
264The role of
265.Nm
266is so critical that if it dies, the system will reboot itself
267automatically.
268If, at bootstrap time, the
269.Nm
270process cannot be located, the system will panic with the message
271``panic: "init died (signal %d, exit %d)''.
272.Sh DIAGNOSTICS
273.Bl -diag
274.It "getty repeating too quickly on port %s, sleeping"
275A process being started to service a line is exiting quickly
276each time it is started.
277This is often caused by a ringing or noisy terminal line.
278.Em "Init will sleep for 10 seconds" ,
279.Em "then continue trying to start the process" .
280.Pp
281.It "some processes would not die; ps axl advised."
282A process
283is hung and could not be killed when the system was shutting down.
284This condition is usually caused by a process
285that is stuck in a device driver because of
286a persistent device error condition.
287.El
288.Sh FILES
289.Bl -tag -width /var/log/wtmp -compact
290.It Pa /dev/console
291system console device
292.It Pa /dev/tty*
293terminal ports found in
294.Xr ttys 5
295.It Pa /var/run/utmp
296record of current users on the system
297.It Pa /var/log/wtmp
298record of all logins and logouts
299.It Pa /etc/ttys
300the terminal initialization information file
301.It Pa /etc/rc
302system startup commands
303.It Pa /etc/rc.shutdown
304system shutdown commands
305.El
306.Sh SEE ALSO
307.Xr kill 1 ,
308.Xr login 1 ,
309.Xr sh 1 ,
310.Xr ipfirewall 4 ,
311.Xr ttys 5 ,
312.Xr crash 8 ,
313.Xr getty 8 ,
314.Xr halt 8 ,
315.Xr ipfw 8 ,
316.Xr rc 8 ,
317.Xr reboot 8 ,
318.Xr shutdown 8 ,
319.Xr sysctl 8
320.Sh HISTORY
321A
322.Nm
323command appeared in
324.At v6 .
325.Sh CAVEATS
326Systems without
327.Xr sysctl
328behave as though they have security level \-1.
329.Pp
330Setting the security level above 1 too early in the boot sequence can
331prevent
332.Xr fsck 8
333from repairing inconsistent filesystems.  The
334preferred location to set the security level is at the end of
335.Pa /etc/rc
336after all multi-user startup actions are complete.
337