xref: /freebsd/sbin/init/init.8 (revision 952d112864d8008aa87278a30a539d888a8493cd)
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.8 1997/02/22 14:32:34 peter 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 init
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 init
56commences single user operation by giving
57the super-user a shell on the console.
58The
59.Nm init
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 init
70to run the
71.Pa /etc/rc
72start up command file in fastboot mode (skipping disk checks).
73.Pp
74If the
75.Nm console
76entry in the
77.Xr ttys 5
78file is marked ``insecure'',
79then
80.Nm init
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.Nm 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 init
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.
95.It Ic 0
96Insecure mode \- immutable and append-only flags may be turned off.
97All devices may be read or written subject to their permissions.
98.It Ic 1
99Secure mode \- the system immutable and system append-only flags may not
100be turned off;
101disks for mounted filesystems,
102.Pa /dev/mem ,
103and
104.Pa /dev/kmem
105may not be opened for writing.
106.It Ic 2
107Highly secure mode \- same as secure mode, plus disks may not be
108opened for writing (except by
109.Xr mount 2 )
110whether mounted or not.
111This level precludes tampering with filesystems by unmounting them,
112but also inhibits running
113.Xr newfs 8
114while the system is multi-user.
115.El
116.Pp
117If the security level is initially -1, then
118.Nm init
119leaves it unchanged.
120Otherwise,
121.Nm init
122arranges to run the system in level 0 mode while single user
123and in level 1 mode while multiuser.
124If level 2 mode is desired while running multiuser,
125it can be set while single user, e.g., in the startup script
126.Pa /etc/rc ,
127using
128.Xr sysctl 8 .
129.Pp
130In multi-user operation,
131.Nm init
132maintains
133processes for the terminal ports found in the file
134.Xr ttys 5 .
135.Nm Init
136reads this file, and executes the command found in the second field.
137This command is usually
138.Xr getty 8 ;
139.Nm getty
140opens and initializes the tty line
141and
142executes the
143.Xr login 1
144program.
145The
146.Nm login
147program, when a valid user logs in,
148executes a shell for that user.  When this shell
149dies, either because the user logged out
150or an abnormal termination occurred (a signal),
151the
152.Nm init
153program wakes up, deletes the user
154from the
155.Xr utmp 5
156file of current users and records the logout in the
157.Xr wtmp 5
158file.
159The cycle is
160then restarted by
161.Nm init
162executing a new
163.Nm getty
164for the line.
165.Pp
166Line status (on, off, secure, getty, or window information)
167may be changed in the
168.Xr ttys 5
169file without a reboot by sending the signal
170.Dv SIGHUP
171to
172.Nm init
173with the command
174.Dq Li "kill -HUP 1" .
175On receipt of this signal,
176.Nm init
177re-reads the
178.Xr ttys 5
179file.
180When a line is turned off in
181.Xr ttys 5 ,
182.Nm init
183will send a SIGHUP signal to the controlling process
184for the session associated with the line.
185For any lines that were previously turned off in the
186.Xr ttys 5
187file and are now on,
188.Nm init
189executes a new
190.Nm getty
191to enable a new login.
192If the getty or window field for a line is changed,
193the change takes effect at the end of the current
194login session (e.g., the next time
195.Nm init
196starts a process on the line).
197If a line is commented out or deleted from
198.Xr ttys 5 ,
199.Nm init
200will not do anything at all to that line.
201However, it will complain that the relationship between lines
202in the
203.Xr ttys 5
204file and records in the
205.Xr utmp 5
206file is out of sync,
207so this practice is not recommended.
208.Pp
209.Nm Init
210will terminate multi-user operations and resume single-user mode
211if sent a terminate
212.Pq Dv TERM
213signal, for example,
214.Dq Li "kill \-TERM 1" .
215If there are processes outstanding that are deadlocked (because of
216hardware or software failure),
217.Nm init
218will not wait for them all to die (which might take forever), but
219will time out after 30 seconds and print a warning message.
220.Pp
221.Nm Init
222will cease creating new
223.Nm getty Ns 's
224and allow the system to slowly die away, if it is sent a terminal stop
225.Pq Dv TSTP
226signal, i.e.
227.Dq Li "kill \-TSTP 1" .
228A later hangup will resume full
229multi-user operations, or a terminate will start a single user shell.
230This hook is used by
231.Xr reboot 8
232and
233.Xr halt 8 .
234.Pp
235.Nm Init
236will terminate all possible processes (again, it will not wait
237for deadlocked processes) and reboot the machine if sent the interrupt
238.Pq Dv INT
239signal, i.e.
240.Dq Li "kill \-INT 1".
241This is useful for shutting the machine down cleanly from inside the kernel
242or from X when the machine appears to be hung.
243.Pp
244The role of
245.Nm init
246is so critical that if it dies, the system will reboot itself
247automatically.
248If, at bootstrap time, the
249.Nm init
250process cannot be located, the system will panic with the message
251``panic: "init died (signal %d, exit %d)''.
252.Sh DIAGNOSTICS
253.Bl -diag
254.It "getty repeating too quickly on port %s, sleeping"
255A process being started to service a line is exiting quickly
256each time it is started.
257This is often caused by a ringing or noisy terminal line.
258.Em "Init will sleep for 10 seconds" ,
259.Em "then continue trying to start the process" .
260.Pp
261.It "some processes would not die; ps axl advised."
262A process
263is hung and could not be killed when the system was shutting down.
264This condition is usually caused by a process
265that is stuck in a device driver because of
266a persistent device error condition.
267.El
268.Sh FILES
269.Bl -tag -width /var/log/wtmp -compact
270.It Pa /dev/console
271System console device.
272.It Pa /dev/tty*
273Terminal ports found in
274.Xr ttys 5 .
275.It Pa /var/run/utmp
276Record of Current users on the system.
277.It Pa /var/log/wtmp
278Record of all logins and logouts.
279.It Pa /etc/ttys
280The terminal initialization information file.
281.It Pa /etc/rc
282System startup commands.
283.El
284.Sh SEE ALSO
285.Xr kill 1 ,
286.Xr login 1 ,
287.Xr sh 1 ,
288.Xr ttys 5 ,
289.Xr crash 8 ,
290.Xr getty 8 ,
291.Xr halt 8 ,
292.Xr rc 8 ,
293.Xr reboot 8 ,
294.Xr shutdown 8
295.Sh HISTORY
296A
297.Nm
298command appeared in
299.At v6 .
300.Sh BUGS
301Systems without
302.Xr sysctl
303behave as though they have security level \-1.
304