1 .\" Copyright (c) 2011-2016 Devin Teske
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .Nd safely edit system rc files
36 .Op Fl j Ar jail | Fl R Ar dir
37 .Ar name Ns Op Ns Oo +|- Oc Ns = Ns Ar value
43 .Op Fl j Ar jail | Fl R Ar dir
59 variables from the collection of system rc files and allows processes with
60 appropriate privilege to change values in a safe and effective manner.
62 The following options are available:
63 .Bl -tag -width indent+
65 Dump a list of all non-default configuration variables.
67 Dump a list of all configuration variables
71 For querying, return success if all requested variables are set
73 otherwise return error status.
74 For assignments, return success if no changes are required, otherwise failure.
77 prints a message stating whether variables are set and/or changes are required.
79 Print a description of the given variable.
81 Show default value(s) only (this is the same as setting RC_CONFS to NULL or
82 passing `-f' with a NULL file-argument).
84 Print query results as
87 .Pq for example, Ql var=value .
98 to list configuration files, only list those that exist.
99 When changing a setting, prefer to modify existing files.
101 Operate on the specified file(s) instead of the files obtained by reading the
106 This option can be specified multiple times for additional files.
110 file each directive is in.
112 Print a short usage message to stderr and exit.
114 Print a full usage statement to stderr and exit.
116 Ignore unknown variables.
123 .Pq overrides So Fl R Ar dir Sc ; requires Xr jexec 8 .
125 List configuration files used at startup on stdout and exit.
127 List all configuration files including rc.conf.d entries on stdout and exit.
132 to show service names.
134 exits with success if all named services are installed, failure otherwise.
136 Show only variable values, not their names.
138 Show only variable names, not their values.
141 Disable verbose and hide certain errors.
146 arguments, provide only exit status and no output.
148 Operate within the root directory
167 entries as potential overrides to
171 for additional information on
175 to list configuration files used by service at startup.
178 Print the pathname of the specific
180 file where the directive was found.
182 Print version information to stdout and exit.
184 Remove variable(s) from specified file(s).
187 This utility has a similar syntax to
189 It shares the `-e' and `-n' options
191 and also has the same
193 syntax for making queries/assignments.
195 .Pq but unlike Xr sysctl 8 ,
197 is supported for adding items to values
198 .Pq see APPENDING VALUES
201 is supported for removing items from values
202 .Pq see SUBTRACTING VALUES .
206 serves to query/modify MIBs in the entrant kernel,
208 instead works on values in the system
212 The list of system configuration files is configured in the file
213 .Ql /etc/defaults/rc.conf
216 which by-default contains a space-separated list of pathnames.
219 systems, this defaults to the value "/etc/rc.conf /etc/rc.conf.local".
221 pathname is sourced in-order upon startup.
222 It is in the same fashion that
224 sources the configuration files before returning the value of the given
227 When supplied a variable name,
229 will return the value of the variable.
230 If the variable does not appear in any
233 an error is printed and error status is returned.
235 When changing values of a given variable, it does not matter if the variable
236 appears in any of the
239 If the variable does not appear in any of the files, it is appended to
240 the end of the first pathname in the
245 will replace only the last-occurrence in the last-file found to contain the
247 This gets the value to take effect next boot without heavily
248 modifying these integral files (yet taking care not to allow the file to
251 be called repeatedly).
255 syntax to add items to existing values,
256 the first character of the value is taken as the delimiter separating items
257 .Pq usually Qo " " Qc or Qo , Qc .
258 For example, in the following statement:
259 .Bl -item -offset indent
262 cloned_interfaces+=" gif0"
265 the first character is a space, informing
267 that existing values are to be considered separated by whitespace.
270 is not found in the existing value for
271 .Va cloned_interfaces ,
273 .Pq with delimiter only if existing value is non-NULL .
275 For convenience, if the first character is alpha-numeric
276 .Pq letters A-Z, a-z, or numbers 0-9 ,
282 uses the default setting of whitespace as separator.
283 For example, the above and below statements are equivalent since
285 starts with an alpha-numeric character
286 .Pq the letter Li g :
287 .Bl -item -offset indent
290 cloned_interfaces+=gif0
293 Take the following sequence for example:
294 .Bl -item -offset indent
297 cloned_interfaces= # start with NULL
300 cloned_interfaces+=gif0
301 .Dl # NULL -> `gif0' Pq NB: no preceding delimiter
304 cloned_interfaces+=gif0 # no change
307 cloned_interfaces+="tun0 gif0"
308 .Dl # `gif0' -> `gif0 tun0' Pq NB: no duplication
312 prevents the same value from being added if already there.
313 .Sh SUBTRACTING VALUES
316 syntax to remove items from existing values,
317 the first character of the value is taken as the delimiter separating items
318 .Pq usually Qo " " Qc or Qo , Qc .
319 For example, in the following statement:
321 .Dl Nm cloned_interfaces-=" gif0"
323 the first character is a space, informing
325 that existing values are to be considered separated by whitespace.
328 is found in the existing value for
329 .Va cloned_interfaces ,
331 .Pq extra delimiters removed .
333 For convenience, if the first character is alpha-numeric
334 .Pq letters A-Z, a-z, or numbers 0-9 ,
340 uses the default setting of whitespace as separator.
341 For example, the above and below statements are equivalent since
343 starts with an alpha-numeric character
344 .Pq the letter Li g :
345 .Bl -item -offset indent
348 cloned_interfaces-=gif0
351 Take the following sequence for example:
352 .Bl -item -offset indent
355 foo="bar baz" # start
358 foo-=bar # `bar baz' -> `baz'
361 foo-=baz # `baz' -> NULL
365 removes all occurrences of all items provided
366 and collapses extra delimiters between items.
368 The following environment variables are referenced by
370 .Bl -tag -width ".Ev RC_DEFAULTS"
374 .Pq even if set to NULL .
377 .Ql /etc/defaults/rc.conf
381 The following standard commands are required by
401 .Bl -tag -width ".Pa /etc/defaults/rc.conf" -compact
402 .It Pa /etc/defaults/rc.conf
404 .It Pa /etc/rc.conf.local
405 .It Pa /etc/rc.conf.d/name
406 .It Pa /etc/rc.conf.d/name/*
407 .It Pa /usr/local/etc/rc.conf.d/name
408 .It Pa /usr/local/etc/rc.conf.d/name/*
411 Below are some simple examples of how
413 can be used to query certain values from the
415 collection of system configuration files:
419 .Dl returns the value of $sshd_enable, usually YES or NO .
423 .Dl returns IP address of default router Pq if configured .
425 Working on other files, such as
429 -f /etc/crontab MAILTO
430 .Dl returns the value of the MAILTO setting Pq if configured .
432 Appending to existing values:
435 \&cloned_interfaces+=gif0
436 .Dl appends Qo gif0 Qc to $cloned_interfaces Pq see APPENDING VALUES .
439 \&cloned_interfaces-=gif0
440 .Dl removes Qo gif0 Qc from $cloned_interfaces Pq see SUBTRACTING VALUES .
442 In addition to the above syntax,
446 PARAMETER expansion for changing the way values are reported, shown below:
450 .Dl returns $hostname up to (but not including) first `.' .
453 \&'network_interfaces%%[$IFS]*'
454 .Dl returns first word of $network_interfaces .
457 \&'ntpdate_flags##*[$IFS]'
458 .Dl returns last word of $ntpdate_flags (time server address) .
462 .Dl returns $usbd_flags or "default" if unset or NULL .
465 cloned_interfaces+"alternate"
466 .Dl returns "alternate" if $cloned_interfaces is set .
478 utility first appeared in
481 .An Devin Teske Aq Mt dteske@FreeBSD.org
483 Brandon Gooch, Enji Cooper, Julian Elischer, Pawel Jakub Dawidek,
484 Cyrille Lefevre, Ross West, Stefan Esser, Marco Steinbach, Jilles Tjoelker,
485 Allan Jude, and Lars Engels for suggestions, help, and testing.