xref: /openbsd-src/share/man/man8/rc.8 (revision 0b7734b3d77bb9b21afec6f4621cae6c805dbd45)
1.\"	$OpenBSD: rc.8,v 1.42 2015/11/21 19:43:50 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 $Mdocdate: November 21 2015 $
33.Dt RC 8
34.Os
35.Sh NAME
36.Nm rc ,
37.Nm rc.firsttime ,
38.Nm rc.local ,
39.Nm rc.securelevel
40.Nd command scripts for system startup
41.Sh SYNOPSIS
42.Nm /etc/rc
43.Nm /etc/rc.firsttime
44.Nm /etc/rc.local
45.Nm /etc/rc.securelevel
46.Sh DESCRIPTION
47.Nm rc
48is the command script that is invoked by
49.Xr init 8
50when the system starts up.
51It performs system housekeeping chores and starts up system daemons.
52Additionally,
53.Nm rc
54is intricately tied to the
55.Xr netstart 8
56script, which runs commands and daemons pertaining to the network.
57.Nm rc
58is also used to execute any
59.Xr rc.d 8
60scripts defined in
61.Xr rc.conf.local 8 .
62The
63.Nm rc.securelevel ,
64.Nm rc.firsttime ,
65and
66.Nm rc.local
67scripts hold commands which are pertinent only to a specific site.
68.Pp
69All of these startup scripts are controlled to some
70extent by variables defined in
71.Xr rc.conf 8 ,
72which specify which daemons and services to run.
73.Pp
74Before
75.Xr init 8
76starts
77.Nm rc ,
78it sets the process priority, umask, and resource limits according to the
79.Dq daemon
80login class as described in
81.Xr login.conf 5 .
82It then starts
83.Nm rc
84and attempts to execute the sequence of commands therein.
85.Pp
86The first part of
87.Nm rc
88runs an
89.Xr fsck 8
90with option
91.Fl p
92to
93.Dq preen
94all disks of minor inconsistencies resulting
95from the last system shutdown and to check for serious inconsistencies
96caused by hardware or software failure.
97If this auto-check and repair succeeds, then the second part of
98.Nm rc
99is run.
100However, if the file
101.Pa /fastboot
102exists,
103fsck will not be invoked.
104The file is then removed so that fsck will be run on subsequent boots.
105.Pp
106The second part of
107.Nm rc
108then asks
109.Xr rc.conf 8
110for configuration variables,
111mounts filesystems, saves
112.Xr dmesg 8
113output to the file
114.Pa /var/run/dmesg.boot ,
115starts system daemons,
116preserves editor files,
117clears the scratch directory
118.Pa /tmp ,
119and saves any possible core image that might have been
120generated as a result of a system crash, with
121.Xr savecore 8 .
122.Pp
123If at any point the boot script fails,
124.Xr init 8
125enters single-user mode,
126allowing the superuser a shell on the console.
127On exiting this mode,
128init again invokes
129.Nm rc ,
130but this time without performing the file system preen.
131.Pp
132Before
133.Nm rc
134starts most system daemons,
135.Xr netstart 8
136is executed.
137.Pp
138.Nm rc.securelevel
139is executed by
140.Nm rc
141to start daemons that must be run before the security level changes.
142Following this,
143.Nm rc
144then sets the security level to '1' if it wasn't set already by
145.Nm rc.securelevel .
146See
147.Xr securelevel 7
148for the effects of setting the security level.
149.Pp
150If
151.Nm rc.firsttime
152exists, it is executed once and then deleted.
153Any output is mailed to root.
154.Pp
155.Nm rc.local
156is executed towards the end of
157.Nm rc
158(it is not the very last as there are a few services that must be
159started at the very end).
160Normally,
161.Nm rc.local
162contains commands and daemons that are not part of the
163stock installation.
164.Sh FILES
165.Bl -tag -width "/etc/rc.securelevelXX" -compact
166.It Pa /etc/netstart
167Command script for network startup.
168.It Pa /etc/rc
169Command scripts for system startup.
170.It Pa /etc/rc.conf
171System daemon configuration database.
172.It Pa /etc/rc.conf.local
173Site specific daemon configuration database.
174.It Pa /etc/rc.d
175Directory to hold
176.Xr rc.d 8
177scripts.
178.It Pa /etc/rc.d/rc.subr
179Functions used by the
180.Xr rc.d 8
181scripts.
182.It Pa /etc/rc.firsttime
183Commands run on the first boot after creation.
184.It Pa /etc/rc.local
185Site specific command scripts for system startup.
186.It Pa /etc/rc.securelevel
187Commands run before the security level changes.
188.It Pa /etc/rc.shutdown
189Commands run at system shutdown.
190.It Pa /fastboot
191Tells
192.Nm rc
193not to run
194.Xr fsck 8
195during the next boot.
196.It Pa /var/run/dmesg.boot
197copy of
198.Xr dmesg 8
199saved by
200.Nm rc
201at boot time
202.El
203.Sh SEE ALSO
204.Xr sysctl.conf 5 ,
205.Xr securelevel 7 ,
206.Xr init 8 ,
207.Xr netstart 8 ,
208.Xr rc.conf 8 ,
209.Xr rc.d 8 ,
210.Xr rc.shutdown 8 ,
211.Xr rcctl 8
212.Sh HISTORY
213The
214.Nm
215command appeared in
216.Bx 4.0 .
217