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