1.\" $OpenBSD: rc.8,v 1.21 2003/07/29 12:42:37 jmc 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 December 11, 1993 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.conf 41.Nm /etc/rc.local 42.Nm /etc/rc.securelevel 43.Nm /etc/netstart 44.Nm /etc/rc.shutdown 45.Sh DESCRIPTION 46.Nm rc 47is the command script that is invoked by 48.Xr init 8 49during an automatic reboot and after single user mode is exited; 50it performs system housekeeping chores and starts up system daemons. 51As well, 52.Nm rc 53is intricately tied to the 54.Nm netstart 55script, which runs commands and daemons pertaining to the network. 56The 57.Nm rc.securelevel 58and 59.Nm rc.local 60scripts hold commands which are pertinent only to a specific site. 61.Pp 62All four of these startup scripts are (or can be) controlled to some 63extent by variables defined in 64.Nm rc.conf , 65which specifies which daemons and services are to be run. 66.Pp 67When an automatic reboot is in progress, 68.Nm rc 69is invoked with the argument 70.Em autoboot . 71The first portion of 72.Nm rc 73runs an 74.Xr fsck 8 75with option 76.Fl p 77to 78.Dq preen 79all disks of minor inconsistencies resulting 80from the last system shutdown and to check for serious inconsistencies 81caused by hardware or software failure. 82If this auto-check and repair succeeds, then the second part of 83.Nm rc 84is run. 85.Pp 86However, if the file 87.Pa /fastboot 88exists, 89.Xr fsck 8 90will not be invoked during this boot. 91This file is then removed so that it will be run on subsequent boots. 92.Pp 93The second part of 94.Nm rc , 95which is run after an auto-reboot succeeds and also if 96.Nm rc 97is invoked when a single user shell terminates (see 98.Xr init 8 ) , 99then asks 100.Nm rc.conf 101for configuration variables, 102mounts filesystems, starts system daemons, 103preserves editor files, 104clears the scratch directory 105.Pa /tmp , 106and saves any possible core image that might have been 107generated as a result of a system crash, with 108.Xr savecore 8 . 109.Pp 110Before 111.Nm rc 112starts most system daemons, 113.Xr netstart 8 114is executed. 115.Pp 116.Nm rc.securelevel 117is executed by 118.Nm rc 119to start daemons that must run before the security level changes. 120Following this, 121.Nm rc 122then sets the security level to the value specified in the 123.Va securelevel 124variable in that file. 125.Pp 126.Nm rc.local 127is executed towards the end of 128.Nm rc 129(it is not the very last as there are a few services that must be 130the started at the very end). 131Normally, 132.Nm rc.local 133contains commands and daemons that are not part of the 134stock installation. 135.Sh CONFIGURATION EXAMPLES 136The 137.Nm rc.conf 138file contains a series of Bourne-shell syntax assignments that 139are used to configure kernel configurations, network configuration, 140and various other system daemons. 141As described above, this file is sourced (using 142.Xr sh 1 143of course) by 144.Pa /etc/rc . 145Various comments in 146.Nm rc.conf 147make it clear what each variable does. 148Refer to the specific man pages for each daemon to determine what that 149subsystem does. 150.Pp 151For example, the 152.Xr lpd 8 153daemon is controlled by the line 154.Bd -literal -offset indent 155lpd_flags=NO # for normal use: "" (or "-l" for debugging) 156.Ed 157.Pp 158This does not start 159.Xr lpd 8 160at system startup. 161To start 162.Xr lpd 8 , 163the following entry can be used. 164.Bd -literal -offset indent 165lpd_flags="" # for normal use: "" (or "-l" for debugging) 166.Ed 167.Pp 168Alternately, 169.Xr lpd 8 170can be started with the 171.Fl l 172flag (to log remote connections). 173.Bd -literal -offset indent 174lpd_flags="-l" # for normal use: "" (or "-l" for debugging) 175.Ed 176.Sh EXTERNAL INFLUENCES 177Before 178.Xr init 8 179starts 180.Nm rc , 181it sets the process priority, umask, and resource limits according to the 182.Dq daemon 183login class as described in 184.Pa /etc/login.conf . 185.Sh SEE ALSO 186.Xr login.conf 5 , 187.Xr sysctl.conf 5 , 188.Xr init 8 , 189.Xr netstart 8 , 190.Xr rc.conf 8 , 191.Xr rc.shutdown 8 , 192.Xr reboot 8 , 193.Xr savecore 8 194.Sh HISTORY 195The 196.Nm 197command appeared in 198.Bx 4.0 . 199