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