xref: /freebsd/sbin/init/init.8 (revision 6ebaa024dfafe75350e7fa061dec56f085aaf840)
18fae3551SRodney W. Grimes.\" Copyright (c) 1980, 1991, 1993
28fae3551SRodney W. Grimes.\"	The Regents of the University of California.  All rights reserved.
38fae3551SRodney W. Grimes.\"
48fae3551SRodney W. Grimes.\" This code is derived from software contributed to Berkeley by
58fae3551SRodney W. Grimes.\" Donn Seeley at Berkeley Software Design, Inc.
68fae3551SRodney W. Grimes.\"
78fae3551SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without
88fae3551SRodney W. Grimes.\" modification, are permitted provided that the following conditions
98fae3551SRodney W. Grimes.\" are met:
108fae3551SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright
118fae3551SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer.
128fae3551SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright
138fae3551SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer in the
148fae3551SRodney W. Grimes.\"    documentation and/or other materials provided with the distribution.
158fae3551SRodney W. Grimes.\" 3. All advertising materials mentioning features or use of this software
168fae3551SRodney W. Grimes.\"    must display the following acknowledgement:
178fae3551SRodney W. Grimes.\"	This product includes software developed by the University of
188fae3551SRodney W. Grimes.\"	California, Berkeley and its contributors.
198fae3551SRodney W. Grimes.\" 4. Neither the name of the University nor the names of its contributors
208fae3551SRodney W. Grimes.\"    may be used to endorse or promote products derived from this software
218fae3551SRodney W. Grimes.\"    without specific prior written permission.
228fae3551SRodney W. Grimes.\"
238fae3551SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
248fae3551SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
258fae3551SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
268fae3551SRodney W. Grimes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
278fae3551SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
288fae3551SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
298fae3551SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
308fae3551SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
318fae3551SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
328fae3551SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
338fae3551SRodney W. Grimes.\" SUCH DAMAGE.
348fae3551SRodney W. Grimes.\"
358fae3551SRodney W. Grimes.\"     @(#)init.8	8.3 (Berkeley) 4/18/94
366ebaa024SJoseph Koshy.\"	$Id: init.8,v 1.10 1997/08/02 00:22:48 davidn Exp $
378fae3551SRodney W. Grimes.\"
388fae3551SRodney W. Grimes.Dd April 18, 1994
398fae3551SRodney W. Grimes.Dt INIT 8
408fae3551SRodney W. Grimes.Os BSD 4
418fae3551SRodney W. Grimes.Sh NAME
428fae3551SRodney W. Grimes.Nm init
438fae3551SRodney W. Grimes.Nd process control initialization
448fae3551SRodney W. Grimes.Sh SYNOPSIS
458fae3551SRodney W. Grimes.Nm init
468fae3551SRodney W. Grimes.Sh DESCRIPTION
478fae3551SRodney W. GrimesThe
488fae3551SRodney W. Grimes.Nm init
498fae3551SRodney W. Grimesprogram
508fae3551SRodney W. Grimesis the last stage of the boot process.
518fae3551SRodney W. GrimesIt normally runs the automatic reboot sequence as described in
528fae3551SRodney W. Grimes.Xr reboot 8 ,
538fae3551SRodney W. Grimesand if this succeeds, begins multi-user operation.
548fae3551SRodney W. GrimesIf the reboot scripts fail,
558fae3551SRodney W. Grimes.Nm init
568fae3551SRodney W. Grimescommences single user operation by giving
578fae3551SRodney W. Grimesthe super-user a shell on the console.
588fae3551SRodney W. GrimesThe
598fae3551SRodney W. Grimes.Nm init
608fae3551SRodney W. Grimesprogram may be passed parameters
618fae3551SRodney W. Grimesfrom the boot program to
628fae3551SRodney W. Grimesprevent the system from going multi-user and to instead execute
638fae3551SRodney W. Grimesa single user shell without starting the normal daemons.
648fae3551SRodney W. GrimesThe system is then quiescent for maintenance work and may
658fae3551SRodney W. Grimeslater be made to go to multi-user by exiting the
668fae3551SRodney W. Grimessingle-user shell (with ^D).
678fae3551SRodney W. GrimesThis
688fae3551SRodney W. Grimescauses
698fae3551SRodney W. Grimes.Nm init
708fae3551SRodney W. Grimesto run the
718fae3551SRodney W. Grimes.Pa /etc/rc
728fae3551SRodney W. Grimesstart up command file in fastboot mode (skipping disk checks).
738fae3551SRodney W. Grimes.Pp
748fae3551SRodney W. GrimesIf the
758fae3551SRodney W. Grimes.Nm console
768fae3551SRodney W. Grimesentry in the
778fae3551SRodney W. Grimes.Xr ttys 5
788fae3551SRodney W. Grimesfile is marked ``insecure'',
798fae3551SRodney W. Grimesthen
808fae3551SRodney W. Grimes.Nm init
818fae3551SRodney W. Grimeswill require that the superuser password be
828fae3551SRodney W. Grimesentered before the system will start a single-user shell.
838fae3551SRodney W. GrimesThe password check is skipped if the
848fae3551SRodney W. Grimes.Nm console
858fae3551SRodney W. Grimesis marked as ``secure''.
868fae3551SRodney W. Grimes.Pp
878fae3551SRodney W. GrimesThe kernel runs with four different levels of security.
888fae3551SRodney W. GrimesAny superuser process can raise the security level, but only
898fae3551SRodney W. Grimes.Nm init
908fae3551SRodney W. Grimescan lower it.
9138058917SBruce EvansThe security levels are:
928fae3551SRodney W. Grimes.Bl -tag -width flag
938fae3551SRodney W. Grimes.It Ic -1
9438058917SBruce EvansPermanently insecure mode \- always run the system in level 0 mode.
956ebaa024SJoseph KoshyThis is the default initial value.
968fae3551SRodney W. Grimes.It Ic 0
978fae3551SRodney W. GrimesInsecure mode \- immutable and append-only flags may be turned off.
988fae3551SRodney W. GrimesAll devices may be read or written subject to their permissions.
998fae3551SRodney W. Grimes.It Ic 1
10079665533SMike PritchardSecure mode \- the system immutable and system append-only flags may not
10179665533SMike Pritchardbe turned off;
1028fae3551SRodney W. Grimesdisks for mounted filesystems,
1038fae3551SRodney W. Grimes.Pa /dev/mem ,
1048fae3551SRodney W. Grimesand
1058fae3551SRodney W. Grimes.Pa /dev/kmem
10638058917SBruce Evansmay not be opened for writing.
1078fae3551SRodney W. Grimes.It Ic 2
10838058917SBruce EvansHighly secure mode \- same as secure mode, plus disks may not be
10938058917SBruce Evansopened for writing (except by
11038058917SBruce Evans.Xr mount 2 )
11138058917SBruce Evanswhether mounted or not.
1128fae3551SRodney W. GrimesThis level precludes tampering with filesystems by unmounting them,
1138fae3551SRodney W. Grimesbut also inhibits running
1148fae3551SRodney W. Grimes.Xr newfs 8
1158fae3551SRodney W. Grimeswhile the system is multi-user.
1168fae3551SRodney W. Grimes.El
1178fae3551SRodney W. Grimes.Pp
11838058917SBruce EvansIf the security level is initially -1, then
11938058917SBruce Evans.Nm init
12038058917SBruce Evansleaves it unchanged.
12138058917SBruce EvansOtherwise,
12238058917SBruce Evans.Nm init
12338058917SBruce Evansarranges to run the system in level 0 mode while single user
1248fae3551SRodney W. Grimesand in level 1 mode while multiuser.
12538058917SBruce EvansIf level 2 mode is desired while running multiuser,
12638058917SBruce Evansit can be set while single user, e.g., in the startup script
12738058917SBruce Evans.Pa /etc/rc ,
1288fae3551SRodney W. Grimesusing
1296ebaa024SJoseph Koshy.Xr sysctl 8
1306ebaa024SJoseph Koshyto set the
1316ebaa024SJoseph Koshy.Dq kern.securelevel
1326ebaa024SJoseph Koshyvariable to the required security level.
1338fae3551SRodney W. Grimes.Pp
1348fae3551SRodney W. GrimesIn multi-user operation,
1358fae3551SRodney W. Grimes.Nm init
1368fae3551SRodney W. Grimesmaintains
1378fae3551SRodney W. Grimesprocesses for the terminal ports found in the file
1388fae3551SRodney W. Grimes.Xr ttys 5 .
1398fae3551SRodney W. Grimes.Nm Init
1408fae3551SRodney W. Grimesreads this file, and executes the command found in the second field.
1418fae3551SRodney W. GrimesThis command is usually
1428fae3551SRodney W. Grimes.Xr getty 8 ;
143edf0e5b3SMike Pritchard.Nm getty
1448fae3551SRodney W. Grimesopens and initializes the tty line
1458fae3551SRodney W. Grimesand
1468fae3551SRodney W. Grimesexecutes the
147edf0e5b3SMike Pritchard.Xr login 1
1488fae3551SRodney W. Grimesprogram.
1498fae3551SRodney W. GrimesThe
150edf0e5b3SMike Pritchard.Nm login
1518fae3551SRodney W. Grimesprogram, when a valid user logs in,
1528fae3551SRodney W. Grimesexecutes a shell for that user.  When this shell
1538fae3551SRodney W. Grimesdies, either because the user logged out
1548fae3551SRodney W. Grimesor an abnormal termination occurred (a signal),
1558fae3551SRodney W. Grimesthe
1568fae3551SRodney W. Grimes.Nm init
1578fae3551SRodney W. Grimesprogram wakes up, deletes the user
1588fae3551SRodney W. Grimesfrom the
1598fae3551SRodney W. Grimes.Xr utmp 5
1608fae3551SRodney W. Grimesfile of current users and records the logout in the
161edf0e5b3SMike Pritchard.Xr wtmp 5
1628fae3551SRodney W. Grimesfile.
1638fae3551SRodney W. GrimesThe cycle is
1648fae3551SRodney W. Grimesthen restarted by
1658fae3551SRodney W. Grimes.Nm init
1668fae3551SRodney W. Grimesexecuting a new
167edf0e5b3SMike Pritchard.Nm getty
1688fae3551SRodney W. Grimesfor the line.
1698fae3551SRodney W. Grimes.Pp
1708fae3551SRodney W. GrimesLine status (on, off, secure, getty, or window information)
1718fae3551SRodney W. Grimesmay be changed in the
172edf0e5b3SMike Pritchard.Xr ttys 5
1738fae3551SRodney W. Grimesfile without a reboot by sending the signal
1748fae3551SRodney W. Grimes.Dv SIGHUP
1758fae3551SRodney W. Grimesto
1768fae3551SRodney W. Grimes.Nm init
1778fae3551SRodney W. Grimeswith the command
1788fae3551SRodney W. Grimes.Dq Li "kill -HUP 1" .
1798fae3551SRodney W. GrimesOn receipt of this signal,
1808fae3551SRodney W. Grimes.Nm init
1818fae3551SRodney W. Grimesre-reads the
182edf0e5b3SMike Pritchard.Xr ttys 5
1838fae3551SRodney W. Grimesfile.
1848fae3551SRodney W. GrimesWhen a line is turned off in
185edf0e5b3SMike Pritchard.Xr ttys 5 ,
1868fae3551SRodney W. Grimes.Nm init
1878fae3551SRodney W. Grimeswill send a SIGHUP signal to the controlling process
1888fae3551SRodney W. Grimesfor the session associated with the line.
1898fae3551SRodney W. GrimesFor any lines that were previously turned off in the
190edf0e5b3SMike Pritchard.Xr ttys 5
1918fae3551SRodney W. Grimesfile and are now on,
1928fae3551SRodney W. Grimes.Nm init
1938fae3551SRodney W. Grimesexecutes a new
194edf0e5b3SMike Pritchard.Nm getty
1958fae3551SRodney W. Grimesto enable a new login.
1968fae3551SRodney W. GrimesIf the getty or window field for a line is changed,
1978fae3551SRodney W. Grimesthe change takes effect at the end of the current
1988fae3551SRodney W. Grimeslogin session (e.g., the next time
1998fae3551SRodney W. Grimes.Nm init
2008fae3551SRodney W. Grimesstarts a process on the line).
2018fae3551SRodney W. GrimesIf a line is commented out or deleted from
202edf0e5b3SMike Pritchard.Xr ttys 5 ,
2038fae3551SRodney W. Grimes.Nm init
2048fae3551SRodney W. Grimeswill not do anything at all to that line.
2058fae3551SRodney W. GrimesHowever, it will complain that the relationship between lines
2068fae3551SRodney W. Grimesin the
207edf0e5b3SMike Pritchard.Xr ttys 5
2088fae3551SRodney W. Grimesfile and records in the
209edf0e5b3SMike Pritchard.Xr utmp 5
2108fae3551SRodney W. Grimesfile is out of sync,
2118fae3551SRodney W. Grimesso this practice is not recommended.
2128fae3551SRodney W. Grimes.Pp
2138fae3551SRodney W. Grimes.Nm Init
2148fae3551SRodney W. Grimeswill terminate multi-user operations and resume single-user mode
2158fae3551SRodney W. Grimesif sent a terminate
2168fae3551SRodney W. Grimes.Pq Dv TERM
2178fae3551SRodney W. Grimessignal, for example,
2188fae3551SRodney W. Grimes.Dq Li "kill \-TERM 1" .
2198fae3551SRodney W. GrimesIf there are processes outstanding that are deadlocked (because of
2208fae3551SRodney W. Grimeshardware or software failure),
221edf0e5b3SMike Pritchard.Nm init
2228fae3551SRodney W. Grimeswill not wait for them all to die (which might take forever), but
2238fae3551SRodney W. Grimeswill time out after 30 seconds and print a warning message.
2248fae3551SRodney W. Grimes.Pp
2258fae3551SRodney W. Grimes.Nm Init
2268fae3551SRodney W. Grimeswill cease creating new
227edf0e5b3SMike Pritchard.Nm getty Ns 's
2288fae3551SRodney W. Grimesand allow the system to slowly die away, if it is sent a terminal stop
2298fae3551SRodney W. Grimes.Pq Dv TSTP
2308fae3551SRodney W. Grimessignal, i.e.
2318fae3551SRodney W. Grimes.Dq Li "kill \-TSTP 1" .
2328fae3551SRodney W. GrimesA later hangup will resume full
2338fae3551SRodney W. Grimesmulti-user operations, or a terminate will start a single user shell.
2348fae3551SRodney W. GrimesThis hook is used by
2358fae3551SRodney W. Grimes.Xr reboot 8
2368fae3551SRodney W. Grimesand
2378fae3551SRodney W. Grimes.Xr halt 8 .
2388fae3551SRodney W. Grimes.Pp
239e460cfd3SNate Williams.Nm Init
240e460cfd3SNate Williamswill terminate all possible processes (again, it will not wait
241e460cfd3SNate Williamsfor deadlocked processes) and reboot the machine if sent the interrupt
242e460cfd3SNate Williams.Pq Dv INT
243e460cfd3SNate Williamssignal, i.e.
244e460cfd3SNate Williams.Dq Li "kill \-INT 1".
245e460cfd3SNate WilliamsThis is useful for shutting the machine down cleanly from inside the kernel
2464f3cac8fSAdam Davidor from X when the machine appears to be hung.
247e460cfd3SNate Williams.Pp
2486ebaa024SJoseph KoshyWhen shutting down the machine,
2498889c700SDavid Nugent.Nm init
2508889c700SDavid Nugentwill try to run the
2518889c700SDavid Nugent.Pa /etc/rc.shutdown
2528889c700SDavid Nugentscript. This script can be used to cleanly terminate specific programs such
2538889c700SDavid Nugentas
2548889c700SDavid Nugent.Nm innd
2558889c700SDavid Nugent(the InterNetNews server).
2568889c700SDavid Nugent.Pp
2578fae3551SRodney W. GrimesThe role of
2588fae3551SRodney W. Grimes.Nm init
2598fae3551SRodney W. Grimesis so critical that if it dies, the system will reboot itself
2608fae3551SRodney W. Grimesautomatically.
2618fae3551SRodney W. GrimesIf, at bootstrap time, the
262edf0e5b3SMike Pritchard.Nm init
2638fae3551SRodney W. Grimesprocess cannot be located, the system will panic with the message
2648fae3551SRodney W. Grimes``panic: "init died (signal %d, exit %d)''.
2658fae3551SRodney W. Grimes.Sh DIAGNOSTICS
2668fae3551SRodney W. Grimes.Bl -diag
2678fae3551SRodney W. Grimes.It "getty repeating too quickly on port %s, sleeping"
2688fae3551SRodney W. GrimesA process being started to service a line is exiting quickly
2698fae3551SRodney W. Grimeseach time it is started.
2708fae3551SRodney W. GrimesThis is often caused by a ringing or noisy terminal line.
2718fae3551SRodney W. Grimes.Em "Init will sleep for 10 seconds" ,
2728fae3551SRodney W. Grimes.Em "then continue trying to start the process" .
2738fae3551SRodney W. Grimes.Pp
2748fae3551SRodney W. Grimes.It "some processes would not die; ps axl advised."
2758fae3551SRodney W. GrimesA process
2768fae3551SRodney W. Grimesis hung and could not be killed when the system was shutting down.
2778fae3551SRodney W. GrimesThis condition is usually caused by a process
2788fae3551SRodney W. Grimesthat is stuck in a device driver because of
2798fae3551SRodney W. Grimesa persistent device error condition.
2808fae3551SRodney W. Grimes.El
2818fae3551SRodney W. Grimes.Sh FILES
2828fae3551SRodney W. Grimes.Bl -tag -width /var/log/wtmp -compact
2838fae3551SRodney W. Grimes.It Pa /dev/console
2848fae3551SRodney W. GrimesSystem console device.
2858fae3551SRodney W. Grimes.It Pa /dev/tty*
2868fae3551SRodney W. GrimesTerminal ports found in
287edf0e5b3SMike Pritchard.Xr ttys 5 .
2888fae3551SRodney W. Grimes.It Pa /var/run/utmp
2898fae3551SRodney W. GrimesRecord of Current users on the system.
2908fae3551SRodney W. Grimes.It Pa /var/log/wtmp
2918fae3551SRodney W. GrimesRecord of all logins and logouts.
2928fae3551SRodney W. Grimes.It Pa /etc/ttys
2938fae3551SRodney W. GrimesThe terminal initialization information file.
2948fae3551SRodney W. Grimes.It Pa /etc/rc
2958fae3551SRodney W. GrimesSystem startup commands.
2968889c700SDavid Nugent.It Pa /etc/rc.shutdown
2978889c700SDavid NugentSystem shutdown commands.
2988fae3551SRodney W. Grimes.El
2998fae3551SRodney W. Grimes.Sh SEE ALSO
3008fae3551SRodney W. Grimes.Xr kill 1 ,
301af202156SWolfram Schneider.Xr login 1 ,
3028fae3551SRodney W. Grimes.Xr sh 1 ,
3038fae3551SRodney W. Grimes.Xr ttys 5 ,
3048fae3551SRodney W. Grimes.Xr crash 8 ,
3058fae3551SRodney W. Grimes.Xr getty 8 ,
306af202156SWolfram Schneider.Xr halt 8 ,
3078fae3551SRodney W. Grimes.Xr rc 8 ,
3088fae3551SRodney W. Grimes.Xr reboot 8 ,
3096ebaa024SJoseph Koshy.Xr shutdown 8 ,
3106ebaa024SJoseph Koshy.Xr sysctl 8
3118fae3551SRodney W. Grimes.Sh HISTORY
3128fae3551SRodney W. GrimesA
3138fae3551SRodney W. Grimes.Nm
3148fae3551SRodney W. Grimescommand appeared in
3158fae3551SRodney W. Grimes.At v6 .
3166ebaa024SJoseph Koshy.Sh CAVEATS
3178fae3551SRodney W. GrimesSystems without
3188fae3551SRodney W. Grimes.Xr sysctl
3198fae3551SRodney W. Grimesbehave as though they have security level \-1.
3206ebaa024SJoseph Koshy.Pp
3216ebaa024SJoseph KoshySetting the security level to 2 too early in the boot sequence can
3226ebaa024SJoseph Koshyprevent
3236ebaa024SJoseph Koshy.Xr fsck 8
3246ebaa024SJoseph Koshyfrom repairing inconsistent filesystems.  The
3256ebaa024SJoseph Koshypreferred location to set the security level is at the end of
3266ebaa024SJoseph Koshy.Pa /etc/rc
3276ebaa024SJoseph Koshyafter all multi-user startup actions are complete.
328