xref: /freebsd/sbin/init/init.8 (revision a0a549c7fd970692502ac6326d73ebbe24a496ba)
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
36a0a549c7SRuslan Ermilov.\"	$Id: init.8,v 1.13 1998/12/16 16:50:12 ghelmer 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
485df42cf4SPhilippe Charnier.Nm
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,
555df42cf4SPhilippe Charnier.Nm
568fae3551SRodney W. Grimescommences single user operation by giving
578fae3551SRodney W. Grimesthe super-user a shell on the console.
588fae3551SRodney W. GrimesThe
595df42cf4SPhilippe Charnier.Nm
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
695df42cf4SPhilippe Charnier.Nm
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
755df42cf4SPhilippe Charnier.Em console
768fae3551SRodney W. Grimesentry in the
778fae3551SRodney W. Grimes.Xr ttys 5
788fae3551SRodney W. Grimesfile is marked ``insecure'',
798fae3551SRodney W. Grimesthen
805df42cf4SPhilippe Charnier.Nm
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
845df42cf4SPhilippe Charnier.Em 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
895df42cf4SPhilippe Charnier.Nm
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.
11604b2ac6eSGuy Helmer.It Ic 3
11704b2ac6eSGuy HelmerNetwork secure mode \- same as highly secure mode, plus
11804b2ac6eSGuy HelmerIP packet filter rules (see
11904b2ac6eSGuy Helmer.Xr ipfw 8
12004b2ac6eSGuy Helmerand
12104b2ac6eSGuy Helmer.Xr ipfirewall 4 )
12204b2ac6eSGuy Helmercan not be changed and dummynet configuration can not be adjusted.
1238fae3551SRodney W. Grimes.El
1248fae3551SRodney W. Grimes.Pp
12538058917SBruce EvansIf the security level is initially -1, then
1265df42cf4SPhilippe Charnier.Nm
12738058917SBruce Evansleaves it unchanged.
12838058917SBruce EvansOtherwise,
1295df42cf4SPhilippe Charnier.Nm
13038058917SBruce Evansarranges to run the system in level 0 mode while single user
1318fae3551SRodney W. Grimesand in level 1 mode while multiuser.
13238058917SBruce EvansIf level 2 mode is desired while running multiuser,
13338058917SBruce Evansit can be set while single user, e.g., in the startup script
13438058917SBruce Evans.Pa /etc/rc ,
1358fae3551SRodney W. Grimesusing
1366ebaa024SJoseph Koshy.Xr sysctl 8
1376ebaa024SJoseph Koshyto set the
1386ebaa024SJoseph Koshy.Dq kern.securelevel
1396ebaa024SJoseph Koshyvariable to the required security level.
1408fae3551SRodney W. Grimes.Pp
1418fae3551SRodney W. GrimesIn multi-user operation,
1425df42cf4SPhilippe Charnier.Nm
1438fae3551SRodney W. Grimesmaintains
1448fae3551SRodney W. Grimesprocesses for the terminal ports found in the file
1458fae3551SRodney W. Grimes.Xr ttys 5 .
1468fae3551SRodney W. Grimes.Nm Init
1478fae3551SRodney W. Grimesreads this file, and executes the command found in the second field.
1488fae3551SRodney W. GrimesThis command is usually
1498fae3551SRodney W. Grimes.Xr getty 8 ;
150edf0e5b3SMike Pritchard.Nm getty
1518fae3551SRodney W. Grimesopens and initializes the tty line
1528fae3551SRodney W. Grimesand
1538fae3551SRodney W. Grimesexecutes the
154edf0e5b3SMike Pritchard.Xr login 1
1558fae3551SRodney W. Grimesprogram.
1568fae3551SRodney W. GrimesThe
157edf0e5b3SMike Pritchard.Nm login
1588fae3551SRodney W. Grimesprogram, when a valid user logs in,
1598fae3551SRodney W. Grimesexecutes a shell for that user.  When this shell
1608fae3551SRodney W. Grimesdies, either because the user logged out
1618fae3551SRodney W. Grimesor an abnormal termination occurred (a signal),
1628fae3551SRodney W. Grimesthe
1635df42cf4SPhilippe Charnier.Nm
1648fae3551SRodney W. Grimesprogram wakes up, deletes the user
1658fae3551SRodney W. Grimesfrom the
1668fae3551SRodney W. Grimes.Xr utmp 5
1678fae3551SRodney W. Grimesfile of current users and records the logout in the
168edf0e5b3SMike Pritchard.Xr wtmp 5
1698fae3551SRodney W. Grimesfile.
1708fae3551SRodney W. GrimesThe cycle is
1718fae3551SRodney W. Grimesthen restarted by
1725df42cf4SPhilippe Charnier.Nm
1738fae3551SRodney W. Grimesexecuting a new
174edf0e5b3SMike Pritchard.Nm getty
1758fae3551SRodney W. Grimesfor the line.
1768fae3551SRodney W. Grimes.Pp
1778fae3551SRodney W. GrimesLine status (on, off, secure, getty, or window information)
1788fae3551SRodney W. Grimesmay be changed in the
179edf0e5b3SMike Pritchard.Xr ttys 5
1808fae3551SRodney W. Grimesfile without a reboot by sending the signal
1818fae3551SRodney W. Grimes.Dv SIGHUP
1828fae3551SRodney W. Grimesto
1835df42cf4SPhilippe Charnier.Nm
1848fae3551SRodney W. Grimeswith the command
1858fae3551SRodney W. Grimes.Dq Li "kill -HUP 1" .
1868fae3551SRodney W. GrimesOn receipt of this signal,
1875df42cf4SPhilippe Charnier.Nm
1888fae3551SRodney W. Grimesre-reads the
189edf0e5b3SMike Pritchard.Xr ttys 5
1908fae3551SRodney W. Grimesfile.
1918fae3551SRodney W. GrimesWhen a line is turned off in
192edf0e5b3SMike Pritchard.Xr ttys 5 ,
1935df42cf4SPhilippe Charnier.Nm
1948fae3551SRodney W. Grimeswill send a SIGHUP signal to the controlling process
1958fae3551SRodney W. Grimesfor the session associated with the line.
1968fae3551SRodney W. GrimesFor any lines that were previously turned off in the
197edf0e5b3SMike Pritchard.Xr ttys 5
1988fae3551SRodney W. Grimesfile and are now on,
1995df42cf4SPhilippe Charnier.Nm
2008fae3551SRodney W. Grimesexecutes a new
201edf0e5b3SMike Pritchard.Nm getty
2028fae3551SRodney W. Grimesto enable a new login.
2038fae3551SRodney W. GrimesIf the getty or window field for a line is changed,
2048fae3551SRodney W. Grimesthe change takes effect at the end of the current
2058fae3551SRodney W. Grimeslogin session (e.g., the next time
2065df42cf4SPhilippe Charnier.Nm
2078fae3551SRodney W. Grimesstarts a process on the line).
2088fae3551SRodney W. GrimesIf a line is commented out or deleted from
209edf0e5b3SMike Pritchard.Xr ttys 5 ,
2105df42cf4SPhilippe Charnier.Nm
2118fae3551SRodney W. Grimeswill not do anything at all to that line.
2128fae3551SRodney W. GrimesHowever, it will complain that the relationship between lines
2138fae3551SRodney W. Grimesin the
214edf0e5b3SMike Pritchard.Xr ttys 5
2158fae3551SRodney W. Grimesfile and records in the
216edf0e5b3SMike Pritchard.Xr utmp 5
2178fae3551SRodney W. Grimesfile is out of sync,
2188fae3551SRodney W. Grimesso this practice is not recommended.
2198fae3551SRodney W. Grimes.Pp
2208fae3551SRodney W. Grimes.Nm Init
2218fae3551SRodney W. Grimeswill terminate multi-user operations and resume single-user mode
2228fae3551SRodney W. Grimesif sent a terminate
2238fae3551SRodney W. Grimes.Pq Dv TERM
2248fae3551SRodney W. Grimessignal, for example,
2258fae3551SRodney W. Grimes.Dq Li "kill \-TERM 1" .
2268fae3551SRodney W. GrimesIf there are processes outstanding that are deadlocked (because of
2278fae3551SRodney W. Grimeshardware or software failure),
2285df42cf4SPhilippe Charnier.Nm
2298fae3551SRodney W. Grimeswill not wait for them all to die (which might take forever), but
2308fae3551SRodney W. Grimeswill time out after 30 seconds and print a warning message.
2318fae3551SRodney W. Grimes.Pp
2328fae3551SRodney W. Grimes.Nm Init
2338fae3551SRodney W. Grimeswill cease creating new
234edf0e5b3SMike Pritchard.Nm getty Ns 's
2358fae3551SRodney W. Grimesand allow the system to slowly die away, if it is sent a terminal stop
2368fae3551SRodney W. Grimes.Pq Dv TSTP
2378fae3551SRodney W. Grimessignal, i.e.
2388fae3551SRodney W. Grimes.Dq Li "kill \-TSTP 1" .
2398fae3551SRodney W. GrimesA later hangup will resume full
2408fae3551SRodney W. Grimesmulti-user operations, or a terminate will start a single user shell.
2418fae3551SRodney W. GrimesThis hook is used by
2428fae3551SRodney W. Grimes.Xr reboot 8
2438fae3551SRodney W. Grimesand
2448fae3551SRodney W. Grimes.Xr halt 8 .
2458fae3551SRodney W. Grimes.Pp
246e460cfd3SNate Williams.Nm Init
247e460cfd3SNate Williamswill terminate all possible processes (again, it will not wait
248e460cfd3SNate Williamsfor deadlocked processes) and reboot the machine if sent the interrupt
249e460cfd3SNate Williams.Pq Dv INT
250e460cfd3SNate Williamssignal, i.e.
251e460cfd3SNate Williams.Dq Li "kill \-INT 1".
252e460cfd3SNate WilliamsThis is useful for shutting the machine down cleanly from inside the kernel
2534f3cac8fSAdam Davidor from X when the machine appears to be hung.
254e460cfd3SNate Williams.Pp
255a0a549c7SRuslan Ermilov.Nm Init
256a0a549c7SRuslan Ermilovwill do the same, except it will shutdown the machine if sent
257a0a549c7SRuslan Ermilovthe user defined signal 1
258a0a549c7SRuslan Ermilov.Pq Dv USR1 ,
259a0a549c7SRuslan Ermilovor will shutdown and turn the power off (if hardware permits) if sent
260a0a549c7SRuslan Ermilovthe user defined signal 2
261a0a549c7SRuslan Ermilov.Pq Dv USR2 .
262a0a549c7SRuslan Ermilov.Pp
2636ebaa024SJoseph KoshyWhen shutting down the machine,
2645df42cf4SPhilippe Charnier.Nm
2658889c700SDavid Nugentwill try to run the
2668889c700SDavid Nugent.Pa /etc/rc.shutdown
2678889c700SDavid Nugentscript. This script can be used to cleanly terminate specific programs such
2688889c700SDavid Nugentas
2698889c700SDavid Nugent.Nm innd
2708889c700SDavid Nugent(the InterNetNews server).
2718889c700SDavid Nugent.Pp
2728fae3551SRodney W. GrimesThe role of
2735df42cf4SPhilippe Charnier.Nm
2748fae3551SRodney W. Grimesis so critical that if it dies, the system will reboot itself
2758fae3551SRodney W. Grimesautomatically.
2768fae3551SRodney W. GrimesIf, at bootstrap time, the
2775df42cf4SPhilippe Charnier.Nm
2788fae3551SRodney W. Grimesprocess cannot be located, the system will panic with the message
2798fae3551SRodney W. Grimes``panic: "init died (signal %d, exit %d)''.
2808fae3551SRodney W. Grimes.Sh DIAGNOSTICS
2818fae3551SRodney W. Grimes.Bl -diag
2828fae3551SRodney W. Grimes.It "getty repeating too quickly on port %s, sleeping"
2838fae3551SRodney W. GrimesA process being started to service a line is exiting quickly
2848fae3551SRodney W. Grimeseach time it is started.
2858fae3551SRodney W. GrimesThis is often caused by a ringing or noisy terminal line.
2868fae3551SRodney W. Grimes.Em "Init will sleep for 10 seconds" ,
2878fae3551SRodney W. Grimes.Em "then continue trying to start the process" .
2888fae3551SRodney W. Grimes.Pp
2898fae3551SRodney W. Grimes.It "some processes would not die; ps axl advised."
2908fae3551SRodney W. GrimesA process
2918fae3551SRodney W. Grimesis hung and could not be killed when the system was shutting down.
2928fae3551SRodney W. GrimesThis condition is usually caused by a process
2938fae3551SRodney W. Grimesthat is stuck in a device driver because of
2948fae3551SRodney W. Grimesa persistent device error condition.
2958fae3551SRodney W. Grimes.El
2968fae3551SRodney W. Grimes.Sh FILES
297a0a549c7SRuslan Ermilov.Bl -tag -width /etc/rc.shutdown -compact
2988fae3551SRodney W. Grimes.It Pa /dev/console
2995df42cf4SPhilippe Charniersystem console device
3008fae3551SRodney W. Grimes.It Pa /dev/tty*
3015df42cf4SPhilippe Charnierterminal ports found in
3025df42cf4SPhilippe Charnier.Xr ttys 5
3038fae3551SRodney W. Grimes.It Pa /var/run/utmp
3045df42cf4SPhilippe Charnierrecord of current users on the system
3058fae3551SRodney W. Grimes.It Pa /var/log/wtmp
3065df42cf4SPhilippe Charnierrecord of all logins and logouts
3078fae3551SRodney W. Grimes.It Pa /etc/ttys
3085df42cf4SPhilippe Charnierthe terminal initialization information file
3098fae3551SRodney W. Grimes.It Pa /etc/rc
3105df42cf4SPhilippe Charniersystem startup commands
3118889c700SDavid Nugent.It Pa /etc/rc.shutdown
3125df42cf4SPhilippe Charniersystem shutdown commands
3138fae3551SRodney W. Grimes.El
3148fae3551SRodney W. Grimes.Sh SEE ALSO
3158fae3551SRodney W. Grimes.Xr kill 1 ,
316af202156SWolfram Schneider.Xr login 1 ,
3178fae3551SRodney W. Grimes.Xr sh 1 ,
31804b2ac6eSGuy Helmer.Xr ipfirewall 4 ,
3198fae3551SRodney W. Grimes.Xr ttys 5 ,
3208fae3551SRodney W. Grimes.Xr crash 8 ,
3218fae3551SRodney W. Grimes.Xr getty 8 ,
322af202156SWolfram Schneider.Xr halt 8 ,
32304b2ac6eSGuy Helmer.Xr ipfw 8 ,
3248fae3551SRodney W. Grimes.Xr rc 8 ,
3258fae3551SRodney W. Grimes.Xr reboot 8 ,
3266ebaa024SJoseph Koshy.Xr shutdown 8 ,
3276ebaa024SJoseph Koshy.Xr sysctl 8
3288fae3551SRodney W. Grimes.Sh HISTORY
329a0a549c7SRuslan ErmilovAn
3308fae3551SRodney W. Grimes.Nm
3318fae3551SRodney W. Grimescommand appeared in
3328fae3551SRodney W. Grimes.At v6 .
3336ebaa024SJoseph Koshy.Sh CAVEATS
3348fae3551SRodney W. GrimesSystems without
3358fae3551SRodney W. Grimes.Xr sysctl
3368fae3551SRodney W. Grimesbehave as though they have security level \-1.
3376ebaa024SJoseph Koshy.Pp
33804b2ac6eSGuy HelmerSetting the security level above 1 too early in the boot sequence can
3396ebaa024SJoseph Koshyprevent
3406ebaa024SJoseph Koshy.Xr fsck 8
3416ebaa024SJoseph Koshyfrom repairing inconsistent filesystems.  The
3426ebaa024SJoseph Koshypreferred location to set the security level is at the end of
3436ebaa024SJoseph Koshy.Pa /etc/rc
3446ebaa024SJoseph Koshyafter all multi-user startup actions are complete.
345