xref: /openbsd/sbin/init/init.8 (revision d25d28bf)
1.\"	$OpenBSD: init.8,v 1.48 2016/09/05 12:58:17 jmc Exp $
2.\"	$NetBSD: init.8,v 1.6 1995/03/18 14:56:31 cgd Exp $
3.\"
4.\" Copyright (c) 1980, 1991, 1993
5.\"	The Regents of the University of California.  All rights reserved.
6.\"
7.\" This code is derived from software contributed to Berkeley by
8.\" Donn Seeley at Berkeley Software Design, Inc.
9.\"
10.\" Redistribution and use in source and binary forms, with or without
11.\" modification, are permitted provided that the following conditions
12.\" are met:
13.\" 1. Redistributions of source code must retain the above copyright
14.\"    notice, this list of conditions and the following disclaimer.
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\"    notice, this list of conditions and the following disclaimer in the
17.\"    documentation and/or other materials provided with the distribution.
18.\" 3. Neither the name of the University nor the names of its contributors
19.\"    may be used to endorse or promote products derived from this software
20.\"    without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\"     @(#)init.8	8.6 (Berkeley) 5/26/95
35.\"
36.Dd $Mdocdate: September 5 2016 $
37.Dt INIT 8
38.Os
39.Sh NAME
40.Nm init
41.Nd process control initialization
42.Sh SYNOPSIS
43.Nm init
44.Op Fl fs
45.Sh DESCRIPTION
46The
47.Nm
48program
49is the last stage of the boot process.
50It normally executes the sequence of events described in
51.Xr rc 8
52and begins multi-user operation.
53.Pp
54The kernel may pass the following options to
55.Nm ,
56usually when requested by the
57.Xr boot 8
58program:
59.Bl -tag -width Ds
60.It Fl f
61Activate fastboot mode.
62This is not currently supported by the
63.Ox
64kernel.
65Instead, use the
66.Pa /fastboot
67file as explained in the
68.Xr rc 8
69manual.
70.It Fl s
71Boot directly into single-user mode.
72.El
73.Pp
74Single-user mode is also entered if the boot scripts fail.
75.Pp
76In single-user mode, the
77.Xr rc 8
78script is not run and normal daemons are not started,
79but instead a super-user shell is started on the system console.
80If the
81.Ar console
82entry in the
83.Xr ttys 5
84file does not contain the
85.Dq secure
86flag, then
87.Nm
88will require that the superuser password be
89entered before the system will start a single-user shell.
90The password check is skipped if the
91.Ar console
92is marked as
93.Dq secure .
94.Pp
95In single-user mode, the system is quiescent for maintenance work and may
96later be made to go to multi-user by exiting the
97single-user shell (with ^D).
98This
99causes
100.Nm
101to run the
102.Xr rc 8
103startup command file in fastboot mode (skipping disk checks).
104.Pp
105The kernel
106.Xr securelevel 7
107is normally set to 0 while in single-user mode, and raised to 1 when
108the system begins multi-user operations.
109This action will not take
110place if the securelevel is \-1, and can be modified via the
111.Pa /etc/rc.securelevel
112script.
113.Pp
114In multi-user operation,
115.Nm
116maintains
117processes for the terminal ports found in the file
118.Xr ttys 5 .
119.Nm
120reads this file, and executes the command found in the second field.
121This command is usually
122.Xr getty 8 ;
123.Em getty
124opens and initializes the tty line
125and
126executes the
127.Em login
128program.
129The
130.Em login
131program, when a valid user logs in,
132executes a shell for that user.
133When this shell dies, either because the user logged out
134or an abnormal termination occurred (a signal),
135the
136.Nm
137program wakes up, deletes the user
138from the
139.Xr utmp 5
140file of current users and records the logout in the
141.Em wtmp
142file.
143The cycle is
144then restarted by
145.Nm
146executing a new
147.Em getty
148for the line.
149.Pp
150Line status (on, off, secure, getty, or window information)
151may be changed in the
152.Em ttys
153file without a reboot by sending the signal
154.Dv SIGHUP
155to
156.Nm
157with the command
158.Dq Li "kill \-s HUP 1" .
159On receipt of this signal,
160.Nm
161re-reads the
162.Em ttys
163file.
164When a line is turned off in
165.Em ttys ,
166.Nm
167will send a
168.Dv SIGHUP
169signal to the controlling process
170for the session associated with the line.
171For any lines that were previously turned off in the
172.Em ttys
173file and are now on,
174.Nm
175executes a new
176.Em getty
177to enable a new login.
178If the getty or window field for a line is changed,
179the change takes effect at the end of the current
180login session (e.g., the next time
181.Nm
182starts a process on the line).
183If a line is commented out or deleted from
184.Em ttys ,
185.Nm
186will not do anything at all to that line.
187However, it will complain that the relationship between lines
188in the
189.Em ttys
190file and records in the
191.Em utmp
192file is out of sync,
193so this practice is not recommended.
194.Pp
195.Nm
196will terminate multi-user operations and resume single-user mode
197if sent a terminate
198.Pq Dv TERM
199signal, for example,
200.Dq Li "kill \-s TERM 1" .
201If there are processes outstanding that are deadlocked (because of
202hardware or software failure),
203.Nm
204will not wait for them all to die (which might take forever), but
205will time out after 30 seconds and print a warning message.
206.Pp
207.Nm
208will cease creating new
209.Xr getty 8
210and allow the system to slowly die away, if it is sent a terminal stop
211.Pq Dv TSTP
212signal, i.e.,
213.Dq Li "kill \-s TSTP 1" .
214A later hangup will resume full
215multi-user operations, or a terminate will start a single-user shell.
216This hook is used by
217.Xr reboot 8
218and
219.Xr halt 8 .
220.Pp
221.Nm
222will terminate multi-user operations, kill all
223.Xr getty 8 ,
224and run
225.Pa /etc/rc.shutdown
226if a user-defined signal 1
227.Pq Dv USR1 ,
228user-defined signal 2
229.Pq Dv USR2 ,
230or interrupt
231.Pq Dv INT
232signal is received.
233Following this,
234.Dv USR1
235will halt the system;
236.Dv USR2
237will request a powerdown; and
238.Dv INT
239will cause a reboot.
240.Pa /etc/rc.shutdown
241can specify that a powerdown is requested instead of the action
242specified by the signal.
243.Pp
244The role of
245.Nm
246is so critical that if it dies, the system will reboot itself
247automatically.
248If, at bootstrap time, the
249.Nm
250process cannot be located, the system will panic with the message
251.Dq panic: "init died (signal %d, exit %d)" .
252.Sh RESOURCES
253When
254.Nm
255spawns a process it sets the process priority, umask, and resource
256limits based on
257.Pa /etc/login.conf .
258When starting the
259.Xr rc 8
260files, the login class
261.Dq daemon
262is used.
263When starting a window system or
264.Xr getty 8 ,
265the login class
266.Dq default
267is used.
268No resource changes are made when entering single-user mode.
269.Sh FILES
270.Bl -tag -width /etc/rc.securelevel -compact
271.It Pa /dev/console
272system console device
273.It Pa /dev/tty*
274terminal ports found in
275.Em ttys
276.It Pa /etc/rc
277system startup commands
278.It Pa /etc/rc.securelevel
279commands that run before the security level changes
280.It Pa /etc/rc.shutdown
281script run at shutdown time
282.It Pa /etc/ttys
283terminal initialization information file
284.It Pa /fastboot
285tells
286.Xr rc 8
287not to run
288.Xr fsck 8
289during the next boot
290.It Pa /var/run/utmp
291record of users currently logged in
292.It Pa /var/log/wtmp
293record of all logins and logouts
294.El
295.Sh DIAGNOSTICS
296.Bl -diag
297.It "getty repeating too quickly on port %s, sleeping"
298A process being started to service a line is exiting quickly
299each time it is started.
300This is often caused by a ringing or noisy terminal line.
301.Em "Init will sleep for 10 seconds" ,
302.Em "then continue trying to start the process" .
303.It "some processes would not die; ps axl advised."
304A process
305is hung and could not be killed when the system was shutting down.
306This condition is usually caused by a process
307that is stuck in a device driver because of
308a persistent device error condition.
309.El
310.Sh SEE ALSO
311.Xr kill 1 ,
312.Xr login 1 ,
313.Xr sh 1 ,
314.Xr fbtab 5 ,
315.Xr login.conf 5 ,
316.Xr ttys 5 ,
317.Xr securelevel 7 ,
318.Xr crash 8 ,
319.Xr getty 8 ,
320.Xr halt 8 ,
321.Xr rc 8 ,
322.Xr rc.shutdown 8 ,
323.Xr reboot 8 ,
324.Xr shutdown 8
325.Sh HISTORY
326An
327.Nm
328command appeared in
329.At v6 .
330