xref: /openbsd-src/sbin/init/init.8 (revision db84ebf0f4163b7ac8092d0c998bf2f6a5340709)
1*db84ebf0Scheloha.\"	$OpenBSD: init.8,v 1.50 2018/01/16 15:57:51 cheloha Exp $
2df930be7Sderaadt.\"	$NetBSD: init.8,v 1.6 1995/03/18 14:56:31 cgd Exp $
3df930be7Sderaadt.\"
4df930be7Sderaadt.\" Copyright (c) 1980, 1991, 1993
5df930be7Sderaadt.\"	The Regents of the University of California.  All rights reserved.
6df930be7Sderaadt.\"
7df930be7Sderaadt.\" This code is derived from software contributed to Berkeley by
8df930be7Sderaadt.\" Donn Seeley at Berkeley Software Design, Inc.
9df930be7Sderaadt.\"
10df930be7Sderaadt.\" Redistribution and use in source and binary forms, with or without
11df930be7Sderaadt.\" modification, are permitted provided that the following conditions
12df930be7Sderaadt.\" are met:
13df930be7Sderaadt.\" 1. Redistributions of source code must retain the above copyright
14df930be7Sderaadt.\"    notice, this list of conditions and the following disclaimer.
15df930be7Sderaadt.\" 2. Redistributions in binary form must reproduce the above copyright
16df930be7Sderaadt.\"    notice, this list of conditions and the following disclaimer in the
17df930be7Sderaadt.\"    documentation and/or other materials provided with the distribution.
181ef0d710Smillert.\" 3. Neither the name of the University nor the names of its contributors
19df930be7Sderaadt.\"    may be used to endorse or promote products derived from this software
20df930be7Sderaadt.\"    without specific prior written permission.
21df930be7Sderaadt.\"
22df930be7Sderaadt.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23df930be7Sderaadt.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24df930be7Sderaadt.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25df930be7Sderaadt.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26df930be7Sderaadt.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27df930be7Sderaadt.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28df930be7Sderaadt.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29df930be7Sderaadt.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30df930be7Sderaadt.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31df930be7Sderaadt.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32df930be7Sderaadt.\" SUCH DAMAGE.
33df930be7Sderaadt.\"
34f22e700cSmillert.\"     @(#)init.8	8.6 (Berkeley) 5/26/95
35df930be7Sderaadt.\"
36*db84ebf0Scheloha.Dd $Mdocdate: January 16 2018 $
37df930be7Sderaadt.Dt INIT 8
38fc8533a3Saaron.Os
39df930be7Sderaadt.Sh NAME
40df930be7Sderaadt.Nm init
41df930be7Sderaadt.Nd process control initialization
42df930be7Sderaadt.Sh SYNOPSIS
437349792aSaaron.Nm init
443d18d9f7Sjmc.Op Fl fs
45df930be7Sderaadt.Sh DESCRIPTION
46df930be7SderaadtThe
4758aefd4bSaaron.Nm
48df930be7Sderaadtprogram
49df930be7Sderaadtis the last stage of the boot process.
50c44d9ae4SjmcIt normally executes the sequence of events described in
51f353b6f1Sschwarze.Xr rc 8
52f353b6f1Sschwarzeand begins multi-user operation.
532b55eaedSderaadt.Pp
54f353b6f1SschwarzeThe kernel may pass the following options to
55f353b6f1Sschwarze.Nm ,
56f353b6f1Sschwarzeusually when requested by the
57f353b6f1Sschwarze.Xr boot 8
58f353b6f1Sschwarzeprogram:
592b55eaedSderaadt.Bl -tag -width Ds
602b55eaedSderaadt.It Fl f
612b55eaedSderaadtActivate fastboot mode.
62f353b6f1SschwarzeThis is not currently supported by the
63f353b6f1Sschwarze.Ox
64f353b6f1Sschwarzekernel.
65f353b6f1SschwarzeInstead, use the
66f353b6f1Sschwarze.Pa /fastboot
67f353b6f1Sschwarzefile as explained in the
68f353b6f1Sschwarze.Xr rc 8
69f353b6f1Sschwarzemanual.
703d18d9f7Sjmc.It Fl s
719910a9dfSjmcBoot directly into single-user mode.
722b55eaedSderaadt.El
732b55eaedSderaadt.Pp
74f353b6f1SschwarzeSingle-user mode is also entered if the boot scripts fail.
75df930be7Sderaadt.Pp
76f353b6f1SschwarzeIn single-user mode, the
77f353b6f1Sschwarze.Xr rc 8
78f353b6f1Sschwarzescript is not run and normal daemons are not started,
79f353b6f1Sschwarzebut instead a super-user shell is started on the system console.
80df930be7SderaadtIf the
8158aefd4bSaaron.Ar console
82df930be7Sderaadtentry in the
83df930be7Sderaadt.Xr ttys 5
842325329dSmillertfile does not contain the
852325329dSmillert.Dq secure
862325329dSmillertflag, then
8758aefd4bSaaron.Nm
88a3542fadSaaronwill require that the superuser password be
89df930be7Sderaadtentered before the system will start a single-user shell.
90df930be7SderaadtThe password check is skipped if the
9158aefd4bSaaron.Ar console
9295675cd5Saaronis marked as
9395675cd5Saaron.Dq secure .
94df930be7Sderaadt.Pp
95f353b6f1SschwarzeIn single-user mode, the system is quiescent for maintenance work and may
96f353b6f1Sschwarzelater be made to go to multi-user by exiting the
97f353b6f1Sschwarzesingle-user shell (with ^D).
98f353b6f1SschwarzeThis
99f353b6f1Sschwarzecauses
100f353b6f1Sschwarze.Nm
101f353b6f1Sschwarzeto run the
102f353b6f1Sschwarze.Xr rc 8
103f353b6f1Sschwarzestartup command file in fastboot mode (skipping disk checks).
104f353b6f1Sschwarze.Pp
1056ff8a02cShughThe kernel
1066ff8a02cShugh.Xr securelevel 7
1076ff8a02cShughis normally set to 0 while in single-user mode, and raised to 1 when
1089615e1d4Saaronthe system begins multi-user operations.
1099615e1d4SaaronThis action will not take
1109615e1d4Saaronplace if the securelevel is \-1, and can be modified via the
1116ff8a02cShugh.Pa /etc/rc.securelevel
1126ff8a02cShughscript.
113df930be7Sderaadt.Pp
114df930be7SderaadtIn multi-user operation,
11558aefd4bSaaron.Nm
116df930be7Sderaadtmaintains
117df930be7Sderaadtprocesses for the terminal ports found in the file
118df930be7Sderaadt.Xr ttys 5 .
11958aefd4bSaaron.Nm
120df930be7Sderaadtreads this file, and executes the command found in the second field.
121df930be7SderaadtThis command is usually
122df930be7Sderaadt.Xr getty 8 ;
123ac1aa35bSmpech.Em getty
124df930be7Sderaadtopens and initializes the tty line
125df930be7Sderaadtand
126df930be7Sderaadtexecutes the
127ac1aa35bSmpech.Em login
128df930be7Sderaadtprogram.
129df930be7SderaadtThe
130ac1aa35bSmpech.Em login
131df930be7Sderaadtprogram, when a valid user logs in,
1329615e1d4Saaronexecutes a shell for that user.
1339615e1d4SaaronWhen this shell dies, either because the user logged out
134df930be7Sderaadtor an abnormal termination occurred (a signal),
135df930be7Sderaadtthe
13658aefd4bSaaron.Nm
137df930be7Sderaadtprogram wakes up, deletes the user
138df930be7Sderaadtfrom the
139df930be7Sderaadt.Xr utmp 5
140df930be7Sderaadtfile of current users and records the logout in the
141ac1aa35bSmpech.Em wtmp
142df930be7Sderaadtfile.
143df930be7SderaadtThe cycle is
144df930be7Sderaadtthen restarted by
14558aefd4bSaaron.Nm
146df930be7Sderaadtexecuting a new
147ac1aa35bSmpech.Em getty
148df930be7Sderaadtfor the line.
149df930be7Sderaadt.Pp
150df930be7SderaadtLine status (on, off, secure, getty, or window information)
151df930be7Sderaadtmay be changed in the
152ac1aa35bSmpech.Em ttys
153df930be7Sderaadtfile without a reboot by sending the signal
154df930be7Sderaadt.Dv SIGHUP
155df930be7Sderaadtto
15658aefd4bSaaron.Nm
157df930be7Sderaadtwith the command
158df930be7Sderaadt.Dq Li "kill \-s HUP 1" .
159df930be7SderaadtOn receipt of this signal,
16058aefd4bSaaron.Nm
161df930be7Sderaadtre-reads the
162ac1aa35bSmpech.Em ttys
163df930be7Sderaadtfile.
164df930be7SderaadtWhen a line is turned off in
165ac1aa35bSmpech.Em ttys ,
16658aefd4bSaaron.Nm
1675eaf1a72Saaronwill send a
1685eaf1a72Saaron.Dv SIGHUP
1695eaf1a72Saaronsignal to the controlling process
170df930be7Sderaadtfor the session associated with the line.
171df930be7SderaadtFor any lines that were previously turned off in the
172ac1aa35bSmpech.Em ttys
173df930be7Sderaadtfile and are now on,
17458aefd4bSaaron.Nm
175df930be7Sderaadtexecutes a new
176ac1aa35bSmpech.Em getty
177df930be7Sderaadtto enable a new login.
178df930be7SderaadtIf the getty or window field for a line is changed,
179df930be7Sderaadtthe change takes effect at the end of the current
180df930be7Sderaadtlogin session (e.g., the next time
18158aefd4bSaaron.Nm
182df930be7Sderaadtstarts a process on the line).
183df930be7SderaadtIf a line is commented out or deleted from
184ac1aa35bSmpech.Em ttys ,
18558aefd4bSaaron.Nm
186df930be7Sderaadtwill not do anything at all to that line.
187df930be7SderaadtHowever, it will complain that the relationship between lines
188df930be7Sderaadtin the
189ac1aa35bSmpech.Em ttys
190df930be7Sderaadtfile and records in the
191ac1aa35bSmpech.Em utmp
192df930be7Sderaadtfile is out of sync,
193df930be7Sderaadtso this practice is not recommended.
194df930be7Sderaadt.Pp
19558aefd4bSaaron.Nm
196df930be7Sderaadtwill terminate multi-user operations and resume single-user mode
197df930be7Sderaadtif sent a terminate
198df930be7Sderaadt.Pq Dv TERM
199df930be7Sderaadtsignal, for example,
200df930be7Sderaadt.Dq Li "kill \-s TERM 1" .
201df930be7SderaadtIf there are processes outstanding that are deadlocked (because of
202df930be7Sderaadthardware or software failure),
20358aefd4bSaaron.Nm
204df930be7Sderaadtwill not wait for them all to die (which might take forever), but
205df930be7Sderaadtwill time out after 30 seconds and print a warning message.
206df930be7Sderaadt.Pp
20758aefd4bSaaron.Nm
208df930be7Sderaadtwill cease creating new
209bdee1ef7Sjmc.Xr getty 8
210df930be7Sderaadtand allow the system to slowly die away, if it is sent a terminal stop
211df930be7Sderaadt.Pq Dv TSTP
21242671979Saaronsignal, i.e.,
213df930be7Sderaadt.Dq Li "kill \-s TSTP 1" .
214df930be7SderaadtA later hangup will resume full
215b7797436Sderaadtmulti-user operations, or a terminate will start a single-user shell.
216df930be7SderaadtThis hook is used by
217df930be7Sderaadt.Xr reboot 8
218df930be7Sderaadtand
219df930be7Sderaadt.Xr halt 8 .
220df930be7Sderaadt.Pp
221ab091da3Sderaadt.Nm
222ab091da3Sderaadtwill terminate multi-user operations, kill all
223bdee1ef7Sjmc.Xr getty 8 ,
224dee114d4Sdlgand run
225bdbecee4Sderaadt.Pa /etc/rc.shutdown
226dee114d4Sdlgif a user-defined signal 1
227dee114d4Sdlg.Pq Dv USR1 ,
228dee114d4Sdlguser-defined signal 2
229dee114d4Sdlg.Pq Dv USR2 ,
2304874bb35Sjmcor interrupt
2314874bb35Sjmc.Pq Dv INT
232dee114d4Sdlgsignal is received.
233dee114d4SdlgFollowing this,
234dee114d4Sdlg.Dv USR1
235dee114d4Sdlgwill halt the system;
236bdbecee4Sderaadt.Dv USR2
237dee114d4Sdlgwill request a powerdown; and
238bff23b0cSdlg.Dv INT
239dee114d4Sdlgwill cause a reboot.
240dee114d4Sdlg.Pa /etc/rc.shutdown
241dee114d4Sdlgcan specify that a powerdown is requested instead of the action
242dee114d4Sdlgspecified by the signal.
243ab091da3Sderaadt.Pp
244df930be7SderaadtThe role of
24558aefd4bSaaron.Nm
246df930be7Sderaadtis so critical that if it dies, the system will reboot itself
247df930be7Sderaadtautomatically.
248df930be7SderaadtIf, at bootstrap time, the
24958aefd4bSaaron.Nm
250df930be7Sderaadtprocess cannot be located, the system will panic with the message
251e593fc94Sjmc.Dq panic: "init died (signal %d, exit %d)" .
252fed231abSmillert.Sh RESOURCES
253fed231abSmillertWhen
254fed231abSmillert.Nm
255fed231abSmillertspawns a process it sets the process priority, umask, and resource
256fed231abSmillertlimits based on
257fed231abSmillert.Pa /etc/login.conf .
258fed231abSmillertWhen starting the
259fed231abSmillert.Xr rc 8
260fed231abSmillertfiles, the login class
261fed231abSmillert.Dq daemon
262ac1aa35bSmpechis used.
263ac1aa35bSmpechWhen starting a window system or
264fed231abSmillert.Xr getty 8 ,
265fed231abSmillertthe login class
266fed231abSmillert.Dq default
267ac1aa35bSmpechis used.
2689910a9dfSjmcNo resource changes are made when entering single-user mode.
269df930be7Sderaadt.Sh FILES
2706886354dSaaron.Bl -tag -width /etc/rc.securelevel -compact
271df930be7Sderaadt.It Pa /dev/console
2725eaf1a72Saaronsystem console device
273df930be7Sderaadt.It Pa /dev/tty*
2745eaf1a72Saaronterminal ports found in
275ac1aa35bSmpech.Em ttys
276df930be7Sderaadt.It Pa /etc/rc
2775eaf1a72Saaronsystem startup commands
2786886354dSaaron.It Pa /etc/rc.securelevel
2796886354dSaaroncommands that run before the security level changes
28023b24367Saaron.It Pa /etc/rc.shutdown
28123b24367Saaronscript run at shutdown time
28241281203Sjmc.It Pa /etc/ttys
28341281203Sjmcterminal initialization information file
284966bd936Sjmc.It Pa /fastboot
285966bd936Sjmctells
286966bd936Sjmc.Xr rc 8
287966bd936Sjmcnot to run
288966bd936Sjmc.Xr fsck 8
289966bd936Sjmcduring the next boot
29041281203Sjmc.It Pa /var/run/utmp
29141281203Sjmcrecord of users currently logged in
29241281203Sjmc.It Pa /var/log/wtmp
29341281203Sjmcrecord of all logins and logouts
294df930be7Sderaadt.El
2952b65e200Sjmc.Sh DIAGNOSTICS
2962b65e200Sjmc.Bl -diag
2972b65e200Sjmc.It "getty repeating too quickly on port %s, sleeping"
2982b65e200SjmcA process being started to service a line is exiting quickly
2992b65e200Sjmceach time it is started.
3002b65e200SjmcThis is often caused by a ringing or noisy terminal line.
301*db84ebf0Scheloha.Em "Init will sleep for 30 seconds" ,
3022b65e200Sjmc.Em "then continue trying to start the process" .
3032b65e200Sjmc.It "some processes would not die; ps axl advised."
3042b65e200SjmcA process
3052b65e200Sjmcis hung and could not be killed when the system was shutting down.
3062b65e200SjmcThis condition is usually caused by a process
3072b65e200Sjmcthat is stuck in a device driver because of
3082b65e200Sjmca persistent device error condition.
3092b65e200Sjmc.El
310df930be7Sderaadt.Sh SEE ALSO
311df930be7Sderaadt.Xr kill 1 ,
3127acc01d2Saaron.Xr login 1 ,
313df930be7Sderaadt.Xr sh 1 ,
3147acc01d2Saaron.Xr fbtab 5 ,
315fed231abSmillert.Xr login.conf 5 ,
316df930be7Sderaadt.Xr ttys 5 ,
317720ffc21Shugh.Xr securelevel 7 ,
318df930be7Sderaadt.Xr crash 8 ,
319df930be7Sderaadt.Xr getty 8 ,
3207acc01d2Saaron.Xr halt 8 ,
321df930be7Sderaadt.Xr rc 8 ,
32223b24367Saaron.Xr rc.shutdown 8 ,
323df930be7Sderaadt.Xr reboot 8 ,
3247acc01d2Saaron.Xr shutdown 8
325df930be7Sderaadt.Sh HISTORY
326b7797436SderaadtAn
327df930be7Sderaadt.Nm
328df930be7Sderaadtcommand appeared in
329e2e0d09dSschwarze.At v1 .
330