1.\" $OpenBSD: rc.8,v 1.40 2014/07/22 07:38:52 ajacoutot Exp $ 2.\" 3.\" Copyright (c) 1980, 1991, 1993 4.\" The Regents of the University of California. All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. Neither the name of the University nor the names of its contributors 15.\" may be used to endorse or promote products derived from this software 16.\" without specific prior written permission. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28.\" SUCH DAMAGE. 29.\" 30.\" @(#)rc.8 8.2 (Berkeley) 12/11/93 31.\" 32.Dd $Mdocdate: July 22 2014 $ 33.Dt RC 8 34.Os 35.Sh NAME 36.Nm rc 37.Nd command scripts for system startup 38.Sh SYNOPSIS 39.Nm /etc/rc 40.Nm /etc/rc.firsttime 41.Nm /etc/rc.local 42.Nm /etc/rc.securelevel 43.Sh DESCRIPTION 44.Nm rc 45is the command script that is invoked by 46.Xr init 8 47when the system starts up. 48It performs system housekeeping chores and starts up system daemons. 49Additionally, 50.Nm rc 51is intricately tied to the 52.Xr netstart 8 53script, which runs commands and daemons pertaining to the network. 54.Nm rc 55is also used to execute any 56.Xr rc.d 8 57scripts defined in 58.Xr rc.conf.local 8 . 59The 60.Nm rc.securelevel , 61.Nm rc.firsttime , 62and 63.Nm rc.local 64scripts hold commands which are pertinent only to a specific site. 65.Pp 66All of these startup scripts are controlled to some 67extent by variables defined in 68.Xr rc.conf 8 , 69which specify which daemons and services to run. 70.Pp 71Before 72.Xr init 8 73starts 74.Nm rc , 75it sets the process priority, umask, and resource limits according to the 76.Dq daemon 77login class as described in 78.Xr login.conf 5 . 79It then starts 80.Nm rc 81and attempts to execute the sequence of commands therein. 82.Pp 83The first part of 84.Nm rc 85runs an 86.Xr fsck 8 87with option 88.Fl p 89to 90.Dq preen 91all disks of minor inconsistencies resulting 92from the last system shutdown and to check for serious inconsistencies 93caused by hardware or software failure. 94If this auto-check and repair succeeds, then the second part of 95.Nm rc 96is run. 97However, if the file 98.Pa /fastboot 99exists, 100fsck will not be invoked. 101The file is then removed so that fsck will be run on subsequent boots. 102.Pp 103The second part of 104.Nm rc 105then asks 106.Xr rc.conf 8 107for configuration variables, 108mounts filesystems, saves 109.Xr dmesg 8 110output to the file 111.Pa /var/run/dmesg.boot , 112starts system daemons, 113preserves editor files, 114clears the scratch directory 115.Pa /tmp , 116and saves any possible core image that might have been 117generated as a result of a system crash, with 118.Xr savecore 8 . 119.Pp 120If at any point the boot script fails, 121.Xr init 8 122enters single-user mode, 123allowing the superuser a shell on the console. 124On exiting this mode, 125init again invokes 126.Nm rc , 127but this time without performing the file system preen. 128.Pp 129Before 130.Nm rc 131starts most system daemons, 132.Xr netstart 8 133is executed. 134.Pp 135.Nm rc.securelevel 136is executed by 137.Nm rc 138to start daemons that must be run before the security level changes. 139Following this, 140.Nm rc 141then sets the security level to '1' if it wasn't set already by 142.Nm rc.securelevel . 143See 144.Xr securelevel 7 145for the effects of setting the security level. 146.Pp 147If 148.Nm rc.firsttime 149exists, it is executed once and then deleted. 150Any output is mailed to root. 151.Pp 152.Nm rc.local 153is executed towards the end of 154.Nm rc 155(it is not the very last as there are a few services that must be 156started at the very end). 157Normally, 158.Nm rc.local 159contains commands and daemons that are not part of the 160stock installation. 161.Sh FILES 162.Bl -tag -width "/etc/rc.securelevelXX" -compact 163.It Pa /etc/netstart 164Command script for network startup. 165.It Pa /etc/rc 166Command scripts for system startup. 167.It Pa /etc/rc.conf 168System daemon configuration database. 169.It Pa /etc/rc.conf.local 170Site specific daemon configuration database. 171.It Pa /etc/rc.d 172Directory to hold 173.Xr rc.d 8 174scripts. 175.It Pa /etc/rc.d/rc.subr 176Functions used by the 177.Xr rc.d 8 178scripts. 179.It Pa /etc/rc.firsttime 180Commands run on the first boot after creation. 181.It Pa /etc/rc.local 182Site specific command scripts for system startup. 183.It Pa /etc/rc.securelevel 184Commands run before the security level changes. 185.It Pa /etc/rc.shutdown 186Commands run at system shutdown. 187.It Pa /fastboot 188Tells 189.Nm rc 190not to run 191.Xr fsck 8 192during the next boot. 193.It Pa /var/run/dmesg.boot 194copy of 195.Xr dmesg 8 196saved by 197.Nm rc 198at boot time 199.El 200.Sh SEE ALSO 201.Xr sysctl.conf 5 , 202.Xr securelevel 7 , 203.Xr init 8 , 204.Xr netstart 8 , 205.Xr rc.conf 8 , 206.Xr rc.d 8 , 207.Xr rc.shutdown 8 208.Sh HISTORY 209The 210.Nm 211command appeared in 212.Bx 4.0 . 213