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