xref: /openbsd-src/share/man/man8/rc.8 (revision d13be5d47e4149db2549a9828e244d59dbc43f15)
1.\"	$OpenBSD: rc.8,v 1.38 2011/07/31 12:46:17 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: July 31 2011 $
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 the value specified in the
142.Va securelevel
143variable in that file.
144See
145.Xr securelevel 7
146for the effects of setting the security level.
147.Pp
148If
149.Nm rc.firsttime
150exists, it is executed once and then deleted.
151Any output is mailed to root.
152.Pp
153.Nm rc.local
154is executed towards the end of
155.Nm rc
156(it is not the very last as there are a few services that must be
157started at the very end).
158Normally,
159.Nm rc.local
160contains commands and daemons that are not part of the
161stock installation.
162.Sh FILES
163.Bl -tag -width "/etc/rc.securelevelXX" -compact
164.It Pa /etc/netstart
165Command script for network startup.
166.It Pa /etc/rc
167Command scripts for system startup.
168.It Pa /etc/rc.conf
169System daemon configuration database.
170.It Pa /etc/rc.conf.local
171Site specific daemon configuration database.
172.It Pa /etc/rc.d
173Directory to hold
174.Xr rc.d 8
175scripts.
176.It Pa /etc/rc.d/rc.subr
177Functions used by the
178.Xr rc.d 8
179scripts.
180.It Pa /etc/rc.firsttime
181Commands run on the first boot after creation.
182.It Pa /etc/rc.local
183Site specific command scripts for system startup.
184.It Pa /etc/rc.securelevel
185Commands run before the security level changes.
186.It Pa /etc/rc.shutdown
187Commands run at system shutdown.
188.It Pa /fastboot
189Tells
190.Nm rc
191not to run
192.Xr fsck 8
193during the next boot.
194.It Pa /var/run/dmesg.boot
195copy of
196.Xr dmesg 8
197saved by
198.Nm rc
199at boot time
200.El
201.Sh SEE ALSO
202.Xr sysctl.conf 5 ,
203.Xr securelevel 7 ,
204.Xr init 8 ,
205.Xr netstart 8 ,
206.Xr rc.conf 8 ,
207.Xr rc.d 8 ,
208.Xr rc.shutdown 8
209.Sh HISTORY
210The
211.Nm
212command appeared in
213.Bx 4.0 .
214