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