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