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