xref: /freebsd/sbin/init/init.8 (revision e17c0e3256538c4ceddf4cd8c2a0a1940f89024f)
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.\" 4. Neither the name of the University nor the names of its contributors
168fae3551SRodney W. Grimes.\"    may be used to endorse or promote products derived from this software
178fae3551SRodney W. Grimes.\"    without specific prior written permission.
188fae3551SRodney W. Grimes.\"
198fae3551SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
208fae3551SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
218fae3551SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
228fae3551SRodney W. Grimes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
238fae3551SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
248fae3551SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
258fae3551SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
268fae3551SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
278fae3551SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
288fae3551SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
298fae3551SRodney W. Grimes.\" SUCH DAMAGE.
308fae3551SRodney W. Grimes.\"
318fae3551SRodney W. Grimes.\"     @(#)init.8	8.3 (Berkeley) 4/18/94
327f3dea24SPeter Wemm.\" $FreeBSD$
338fae3551SRodney W. Grimes.\"
348fae3551SRodney W. Grimes.Dd April 18, 1994
358fae3551SRodney W. Grimes.Dt INIT 8
369fe48c6eSRuslan Ermilov.Os
378fae3551SRodney W. Grimes.Sh NAME
388fae3551SRodney W. Grimes.Nm init
398fae3551SRodney W. Grimes.Nd process control initialization
408fae3551SRodney W. Grimes.Sh SYNOPSIS
417c7fb079SRuslan Ermilov.Nm
427c7fb079SRuslan Ermilov.Nm
431681d659SRuslan Ermilov.Oo
441681d659SRuslan Ermilov.Cm 0 | 1 | 6 |
451681d659SRuslan Ermilov.Cm c | q
461681d659SRuslan Ermilov.Oc
478fae3551SRodney W. Grimes.Sh DESCRIPTION
488fae3551SRodney W. GrimesThe
495df42cf4SPhilippe Charnier.Nm
50e1205e80SPhilippe Charnierutility
518fae3551SRodney W. Grimesis the last stage of the boot process.
528fae3551SRodney W. GrimesIt normally runs the automatic reboot sequence as described in
531681d659SRuslan Ermilov.Xr rc 8 ,
548fae3551SRodney W. Grimesand if this succeeds, begins multi-user operation.
558fae3551SRodney W. GrimesIf the reboot scripts fail,
565df42cf4SPhilippe Charnier.Nm
571681d659SRuslan Ermilovcommences single-user operation by giving
588fae3551SRodney W. Grimesthe super-user a shell on the console.
598fae3551SRodney W. GrimesThe
605df42cf4SPhilippe Charnier.Nm
61e1205e80SPhilippe Charnierutility may be passed parameters
628fae3551SRodney W. Grimesfrom the boot program to
638fae3551SRodney W. Grimesprevent the system from going multi-user and to instead execute
641681d659SRuslan Ermilova single-user shell without starting the normal daemons.
658fae3551SRodney W. GrimesThe system is then quiescent for maintenance work and may
668fae3551SRodney W. Grimeslater be made to go to multi-user by exiting the
678fae3551SRodney W. Grimessingle-user shell (with ^D).
688fae3551SRodney W. GrimesThis
698fae3551SRodney W. Grimescauses
705df42cf4SPhilippe Charnier.Nm
718fae3551SRodney W. Grimesto run the
728fae3551SRodney W. Grimes.Pa /etc/rc
738fae3551SRodney W. Grimesstart up command file in fastboot mode (skipping disk checks).
748fae3551SRodney W. Grimes.Pp
758fae3551SRodney W. GrimesIf the
765df42cf4SPhilippe Charnier.Em console
778fae3551SRodney W. Grimesentry in the
788fae3551SRodney W. Grimes.Xr ttys 5
791681d659SRuslan Ermilovfile is marked
801681d659SRuslan Ermilov.Dq insecure ,
818fae3551SRodney W. Grimesthen
825df42cf4SPhilippe Charnier.Nm
831681d659SRuslan Ermilovwill require that the super-user password be
848fae3551SRodney W. Grimesentered before the system will start a single-user shell.
858fae3551SRodney W. GrimesThe password check is skipped if the
865df42cf4SPhilippe Charnier.Em console
871681d659SRuslan Ermilovis marked as
881681d659SRuslan Ermilov.Dq secure .
898fae3551SRodney W. Grimes.Pp
90e17c0e32SGary W. SwearingenIf the system security level (see
91e17c0e32SGary W. Swearingen.Xr security 7 )
92e17c0e32SGary W. Swearingenis initially nonzero, then
935df42cf4SPhilippe Charnier.Nm
9438058917SBruce Evansleaves it unchanged.
9538058917SBruce EvansOtherwise,
965df42cf4SPhilippe Charnier.Nm
9767b661fdSSheldon Hearnraises the level to 1 before going multi-user for the first time.
9801de0116SSheldon HearnSince the level cannot be reduced, it will be at least 1 for
9901de0116SSheldon Hearnsubsequent operation, even on return to single-user.
10067b661fdSSheldon HearnIf a level higher than 1 is desired while running multi-user,
10167b661fdSSheldon Hearnit can be set before going multi-user, e.g., by the startup script
10267b661fdSSheldon Hearn.Xr rc 8 ,
1038fae3551SRodney W. Grimesusing
1046ebaa024SJoseph Koshy.Xr sysctl 8
1056ebaa024SJoseph Koshyto set the
106280b191cSKen Smith.Va kern.securelevel
1076ebaa024SJoseph Koshyvariable to the required security level.
1088fae3551SRodney W. Grimes.Pp
109280b191cSKen SmithIf
110280b191cSKen Smith.Nm
111d04b5dfeSRuslan Ermilovis run in a jail, the security level of the
112280b191cSKen Smith.Dq host system
113280b191cSKen Smithwill not be effected.
114280b191cSKen SmithPart of the information set up in the kernel to support a jail
115e17c0e32SGary W. Swearingenis a per-jail security level.
116280b191cSKen SmithThis allows running a higher security level inside of a jail
117280b191cSKen Smiththan that of the host system.
118280b191cSKen SmithSee
119280b191cSKen Smith.Xr jail 8
120280b191cSKen Smithfor more information about jails.
121280b191cSKen Smith.Pp
1228fae3551SRodney W. GrimesIn multi-user operation,
1235df42cf4SPhilippe Charnier.Nm
1248fae3551SRodney W. Grimesmaintains
1258fae3551SRodney W. Grimesprocesses for the terminal ports found in the file
1268fae3551SRodney W. Grimes.Xr ttys 5 .
127e1205e80SPhilippe CharnierThe
128e1205e80SPhilippe Charnier.Nm
129e1205e80SPhilippe Charnierutility reads this file and executes the command found in the second field,
130f0f4f756SSheldon Hearnunless the first field refers to a device in
131f0f4f756SSheldon Hearn.Pa /dev
132f0f4f756SSheldon Hearnwhich is not configured.
133f0f4f756SSheldon HearnThe first field is supplied as the final argument to the command.
1348fae3551SRodney W. GrimesThis command is usually
1358fae3551SRodney W. Grimes.Xr getty 8 ;
136edf0e5b3SMike Pritchard.Nm getty
1378fae3551SRodney W. Grimesopens and initializes the tty line
1388fae3551SRodney W. Grimesand
1398fae3551SRodney W. Grimesexecutes the
140edf0e5b3SMike Pritchard.Xr login 1
1418fae3551SRodney W. Grimesprogram.
1428fae3551SRodney W. GrimesThe
143edf0e5b3SMike Pritchard.Nm login
1448fae3551SRodney W. Grimesprogram, when a valid user logs in,
1459806e231SRuslan Ermilovexecutes a shell for that user.
1469806e231SRuslan ErmilovWhen this shell
1478fae3551SRodney W. Grimesdies, either because the user logged out
1488fae3551SRodney W. Grimesor an abnormal termination occurred (a signal),
1498fae3551SRodney W. Grimesthe
1505df42cf4SPhilippe Charnier.Nm
151e1205e80SPhilippe Charnierutility wakes up, deletes the user
1528fae3551SRodney W. Grimesfrom the
1538fae3551SRodney W. Grimes.Xr utmp 5
1548fae3551SRodney W. Grimesfile of current users and records the logout in the
155edf0e5b3SMike Pritchard.Xr wtmp 5
1568fae3551SRodney W. Grimesfile.
1578fae3551SRodney W. GrimesThe cycle is
1588fae3551SRodney W. Grimesthen restarted by
1595df42cf4SPhilippe Charnier.Nm
1608fae3551SRodney W. Grimesexecuting a new
161edf0e5b3SMike Pritchard.Nm getty
1628fae3551SRodney W. Grimesfor the line.
1638fae3551SRodney W. Grimes.Pp
164e1205e80SPhilippe CharnierThe
165e1205e80SPhilippe Charnier.Nm
166e1205e80SPhilippe Charnierutility can also be used to keep arbitrary daemons running,
167f0f4f756SSheldon Hearnautomatically restarting them if they die.
168f0f4f756SSheldon HearnIn this case, the first field in the
169f0f4f756SSheldon Hearn.Xr ttys 5
170f0f4f756SSheldon Hearnfile must not reference the path to a configured device node
171f0f4f756SSheldon Hearnand will be passed to the daemon
172f0f4f756SSheldon Hearnas the final argument on its command line.
173f0f4f756SSheldon HearnThis is similar to the facility offered in the
174f0f4f756SSheldon Hearn.At V
175f0f4f756SSheldon Hearn.Pa /etc/inittab .
176f0f4f756SSheldon Hearn.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
200f0f4f756SSheldon Hearnexecutes the command specified in the second field.
201f0f4f756SSheldon HearnIf the command or window field for a line is changed,
2028fae3551SRodney W. Grimesthe change takes effect at the end of the current
2038fae3551SRodney W. Grimeslogin session (e.g., the next time
2045df42cf4SPhilippe Charnier.Nm
2058fae3551SRodney W. Grimesstarts a process on the line).
2068fae3551SRodney W. GrimesIf a line is commented out or deleted from
207edf0e5b3SMike Pritchard.Xr ttys 5 ,
2085df42cf4SPhilippe Charnier.Nm
2098fae3551SRodney W. Grimeswill not do anything at all to that line.
2108fae3551SRodney W. GrimesHowever, it will complain that the relationship between lines
2118fae3551SRodney W. Grimesin the
212edf0e5b3SMike Pritchard.Xr ttys 5
2138fae3551SRodney W. Grimesfile and records in the
214edf0e5b3SMike Pritchard.Xr utmp 5
2158fae3551SRodney W. Grimesfile is out of sync,
2168fae3551SRodney W. Grimesso this practice is not recommended.
2178fae3551SRodney W. Grimes.Pp
218e1205e80SPhilippe CharnierThe
219e1205e80SPhilippe Charnier.Nm
220e1205e80SPhilippe Charnierutility will terminate multi-user operations and resume single-user mode
2218fae3551SRodney W. Grimesif sent a terminate
2228fae3551SRodney W. Grimes.Pq Dv TERM
2238fae3551SRodney W. Grimessignal, for example,
2248fae3551SRodney W. Grimes.Dq Li "kill \-TERM 1" .
2258fae3551SRodney W. GrimesIf there are processes outstanding that are deadlocked (because of
2268fae3551SRodney W. Grimeshardware or software failure),
2275df42cf4SPhilippe Charnier.Nm
2288fae3551SRodney W. Grimeswill not wait for them all to die (which might take forever), but
2298fae3551SRodney W. Grimeswill time out after 30 seconds and print a warning message.
2308fae3551SRodney W. Grimes.Pp
231e1205e80SPhilippe CharnierThe
232e1205e80SPhilippe Charnier.Nm
233e1205e80SPhilippe Charnierutility will cease creating new processes
2348fae3551SRodney W. Grimesand allow the system to slowly die away, if it is sent a terminal stop
2358fae3551SRodney W. Grimes.Pq Dv TSTP
23657e4378bSRuslan Ermilovsignal, i.e.\&
2378fae3551SRodney W. Grimes.Dq Li "kill \-TSTP 1" .
2388fae3551SRodney W. GrimesA later hangup will resume full
2391681d659SRuslan Ermilovmulti-user operations, or a terminate will start a single-user shell.
2408fae3551SRodney W. GrimesThis hook is used by
2418fae3551SRodney W. Grimes.Xr reboot 8
2428fae3551SRodney W. Grimesand
2438fae3551SRodney W. Grimes.Xr halt 8 .
2448fae3551SRodney W. Grimes.Pp
245e1205e80SPhilippe CharnierThe
246e1205e80SPhilippe Charnier.Nm
247e1205e80SPhilippe Charnierutility will 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
25057e4378bSRuslan Ermilovsignal, 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
255e1205e80SPhilippe CharnierThe
256e1205e80SPhilippe Charnier.Nm
257e1205e80SPhilippe Charnierutility will do the same, except it will halt the machine if sent
258a0a549c7SRuslan Ermilovthe user defined signal 1
259a0a549c7SRuslan Ermilov.Pq Dv USR1 ,
2601681d659SRuslan Ermilovor will halt and turn the power off (if hardware permits) if sent
261a0a549c7SRuslan Ermilovthe user defined signal 2
262a0a549c7SRuslan Ermilov.Pq Dv USR2 .
263a0a549c7SRuslan Ermilov.Pp
2646ebaa024SJoseph KoshyWhen shutting down the machine,
2655df42cf4SPhilippe Charnier.Nm
2668889c700SDavid Nugentwill try to run the
2678889c700SDavid Nugent.Pa /etc/rc.shutdown
268ef8f7ac9SSheldon Hearnscript.
269ef8f7ac9SSheldon HearnThis script can be used to cleanly terminate specific programs such
2708889c700SDavid Nugentas
2718889c700SDavid Nugent.Nm innd
2728889c700SDavid Nugent(the InterNetNews server).
2738889c700SDavid Nugent.Pp
2748fae3551SRodney W. GrimesThe role of
2755df42cf4SPhilippe Charnier.Nm
2768fae3551SRodney W. Grimesis so critical that if it dies, the system will reboot itself
2778fae3551SRodney W. Grimesautomatically.
2788fae3551SRodney W. GrimesIf, at bootstrap time, the
2795df42cf4SPhilippe Charnier.Nm
2808fae3551SRodney W. Grimesprocess cannot be located, the system will panic with the message
2811681d659SRuslan Ermilov.Dq "panic: init died (signal %d, exit %d)" .
2821681d659SRuslan Ermilov.Pp
2835d94d8b6SRuslan ErmilovIf run as a user process as shown in the second synopsis line,
2841681d659SRuslan Ermilov.Nm
2851681d659SRuslan Ermilovwill emulate
2861681d659SRuslan Ermilov.At V
2879806e231SRuslan Ermilovbehavior, i.e., super-user can specify the desired
2881681d659SRuslan Ermilov.Em run-level
2891681d659SRuslan Ermilovon a command line, and
2901681d659SRuslan Ermilov.Nm
2911681d659SRuslan Ermilovwill signal the original
292c4d9468eSRuslan Ermilov(PID 1)
2931681d659SRuslan Ermilov.Nm
2941681d659SRuslan Ermilovas follows:
2951681d659SRuslan Ermilov.Bl -column Run-level SIGTERM
296d8aa002eSRuslan Ermilov.It Sy "Run-level	Signal	Action
2971681d659SRuslan Ermilov.It Cm 0 Ta Dv SIGUSR2 Ta "Halt and turn the power off"
2981681d659SRuslan Ermilov.It Cm 1 Ta Dv SIGTERM Ta "Go to single-user mode"
2991681d659SRuslan Ermilov.It Cm 6 Ta Dv SIGINT Ta "Reboot the machine"
3001681d659SRuslan Ermilov.It Cm c Ta Dv SIGTSTP Ta "Block further logins"
3011681d659SRuslan Ermilov.It Cm q Ta Dv SIGHUP Ta Rescan the
3021681d659SRuslan Ermilov.Xr ttys 5
3031681d659SRuslan Ermilovfile
3041681d659SRuslan Ermilov.El
3058fae3551SRodney W. Grimes.Sh FILES
306a0a549c7SRuslan Ermilov.Bl -tag -width /etc/rc.shutdown -compact
3078fae3551SRodney W. Grimes.It Pa /dev/console
3085df42cf4SPhilippe Charniersystem console device
3098fae3551SRodney W. Grimes.It Pa /dev/tty*
3105df42cf4SPhilippe Charnierterminal ports found in
3115df42cf4SPhilippe Charnier.Xr ttys 5
3128fae3551SRodney W. Grimes.It Pa /var/run/utmp
3135df42cf4SPhilippe Charnierrecord of current users on the system
3148fae3551SRodney W. Grimes.It Pa /var/log/wtmp
3155df42cf4SPhilippe Charnierrecord of all logins and logouts
3168fae3551SRodney W. Grimes.It Pa /etc/ttys
3175df42cf4SPhilippe Charnierthe terminal initialization information file
3188fae3551SRodney W. Grimes.It Pa /etc/rc
3195df42cf4SPhilippe Charniersystem startup commands
3208889c700SDavid Nugent.It Pa /etc/rc.shutdown
3215df42cf4SPhilippe Charniersystem shutdown commands
3228fae3551SRodney W. Grimes.El
3236087df9eSRuslan Ermilov.Sh DIAGNOSTICS
3246087df9eSRuslan Ermilov.Bl -diag
3256087df9eSRuslan Ermilov.It "getty repeating too quickly on port %s, sleeping."
3266087df9eSRuslan ErmilovA process being started to service a line is exiting quickly
3276087df9eSRuslan Ermiloveach time it is started.
3286087df9eSRuslan ErmilovThis is often caused by a ringing or noisy terminal line.
3296087df9eSRuslan Ermilov.Bf -emphasis
3306087df9eSRuslan ErmilovInit will sleep for 30 seconds,
3316087df9eSRuslan Ermilovthen continue trying to start the process.
3326087df9eSRuslan Ermilov.Ef
3336087df9eSRuslan Ermilov.It "some processes would not die; ps axl advised."
3346087df9eSRuslan ErmilovA process
3356087df9eSRuslan Ermilovis hung and could not be killed when the system was shutting down.
3366087df9eSRuslan ErmilovThis condition is usually caused by a process
3376087df9eSRuslan Ermilovthat is stuck in a device driver because of
3386087df9eSRuslan Ermilova persistent device error condition.
3396087df9eSRuslan Ermilov.El
3408fae3551SRodney W. Grimes.Sh SEE ALSO
3418fae3551SRodney W. Grimes.Xr kill 1 ,
342af202156SWolfram Schneider.Xr login 1 ,
3438fae3551SRodney W. Grimes.Xr sh 1 ,
3448fae3551SRodney W. Grimes.Xr ttys 5 ,
3458fae3551SRodney W. Grimes.Xr getty 8 ,
346af202156SWolfram Schneider.Xr halt 8 ,
347280b191cSKen Smith.Xr jail 8 ,
3488fae3551SRodney W. Grimes.Xr rc 8 ,
3498fae3551SRodney W. Grimes.Xr reboot 8 ,
350e17c0e32SGary W. Swearingen.Xr security 7 ,
3516ebaa024SJoseph Koshy.Xr shutdown 8 ,
3526ebaa024SJoseph Koshy.Xr sysctl 8
3538fae3551SRodney W. Grimes.Sh HISTORY
354a0a549c7SRuslan ErmilovAn
3558fae3551SRodney W. Grimes.Nm
356e1205e80SPhilippe Charnierutility appeared in
3578fae3551SRodney W. Grimes.At v6 .
3586ebaa024SJoseph Koshy.Sh CAVEATS
3598fae3551SRodney W. GrimesSystems without
3609680d7b6SPhilippe Charnier.Xr sysctl 8
3618fae3551SRodney W. Grimesbehave as though they have security level \-1.
3626ebaa024SJoseph Koshy.Pp
36304b2ac6eSGuy HelmerSetting the security level above 1 too early in the boot sequence can
3646ebaa024SJoseph Koshyprevent
3656ebaa024SJoseph Koshy.Xr fsck 8
3669806e231SRuslan Ermilovfrom repairing inconsistent file systems.
3679806e231SRuslan ErmilovThe
3686ebaa024SJoseph Koshypreferred location to set the security level is at the end of
3696ebaa024SJoseph Koshy.Pa /etc/rc
3706ebaa024SJoseph Koshyafter all multi-user startup actions are complete.
371