xref: /freebsd/usr.sbin/sysconf/sysconf.8 (revision 74cab6e2371fc35b58d5d3d018c7c3ad52809153)
1.\" Copyright (c) 2013-2026 Devin Teske <dteske@FreeBSD.org>
2.\" Copyright (c) 2021-2026 Faraz Vahedi <kfv@FreeBSD.org>
3.\"
4.\" SPDX-License-Identifier: BSD-2-Clause
5.\"
6.Dd September 16, 2026
7.Dt SYSCONF 8
8.Os
9.Sh NAME
10.Nm sysconf
11.Nd read and modify system configuration files
12.Sh SYNOPSIS
13.Nm
14.Ar target
15.Op Fl AcDeFinNqsvVx
16.Op Fl j Ar jail | Fl R Ar dir
17.Op Fl f Ar file | Fl k Ar module
18.Ar name Ns Op Ns Oo +|- Oc Ns = Ns Ar value
19.Ar ...
20.Nm
21.Ar target
22.Op Fl ADeFnNqvV
23.Op Fl j Ar jail | Fl R Ar dir
24.Op Fl f Ar file | Fl k Ar module
25.Fl a
26.Nm
27.Ar target
28.Op Fl AaDinNq
29.Op Fl j Ar jail | Fl R Ar dir
30.Fl d
31.Op Ar name ...
32.Nm
33.Ar target
34.Op Fl E
35.Op Fl j Ar jail | Fl R Ar dir
36.Op Fl k Ar module
37.Fl l | L
38.Nm
39.Cm rc
40.Op Ar sysrc_argument ...
41.Sh DESCRIPTION
42The
43.Nm
44utility reads and modifies the system configuration files of the base
45system,
46completing the native configuration trinity alongside
47.Xr sysctl 8
48.Pq kernel state
49and
50.Xr sysrc 8
51.Pq Xr rc.conf 5 .
52The first positional argument selects a
53.Ar target
54keyword;
55options are equally accepted before it.
56Each target is documented on its own page
57.Pq see Sx TARGETS ;
58shared options and assignment syntax are documented here.
59.Ss Assignment syntax
60A
61.Ar name
62alone reads the current value of the directive,
63while
64.Ar name Ns = Ns Ar value
65atomically writes it.
66Writes echo
67.Ql name: old -> new
68when the stored value changes,
69or
70.Ql name: value (unchanged)
71when it is already set as requested
72.Pq the file is left untouched in that case .
73With
74.Fl e
75those echoes use
76.Ql name=...
77instead of
78.Ql name: ...
79.Pq matching read output .
80The echo is suppressed by
81.Fl q ;
82.Fl c
83writes nothing to stdout.
84A directive not previously set anywhere shows an empty old value.
85.Pp
86On the
87.Cm make
88and
89.Cm src
90targets, a
91.Ql WITH_*
92or
93.Ql WITHOUT_*
94build knob
95.Pq presence matters; Xr src.conf 5 ignores the value
96is shown as
97.Ql name (present)
98when defined
99.Po
100any value, including
101.Ql =
102or
103.Ql =t
104.Pc ,
105rather than printing the value after the colon;
106.Fl e
107prints the real assignment
108.Po
109e.g.
110.Ql name=
111or
112.Ql name=t
113.Pc ,
114and
115.Fl n
116prints that same value alone
117.Pq empty when the assignment is Ql name= .
118Setting such a knob with
119.Fl s
120echoes
121.Ql name: (not present) -> (present)
122.Po
123or
124.Ql (present) (unchanged)
125when it is already defined
126.Pc .
127An explicit
128.Ar name Ns =
129.Pq including empty
130always writes the requested value;
131a change of placeholder while the knob stays defined echoes
132.Ql name: old -> new
133like other assignments.
134A write of
135.Ql WITH_ Ns Ar foo Ns =no
136.Pq exact lowercase Ql no
137is still performed but warns to use
138.Ql WITHOUT_ Ns Ar foo Ns =1
139instead.
140That message matches
141.Pa share/mk/bsd.mkopt.mk
142and is emitted here as a precursor so a bad
143.Xr make.conf 5
144or
145.Xr src.conf 5
146assignment is caught at write time.
147The same advisory is printed on reads
148.Po
149named queries and
150.Fl a
151dump
152.Pc ,
153with
154.Ql file:line:
155when the authoritative statement is known, so an existing
156.Ql WITH_* Ns =no
157is not overlooked when presence display shows only
158.Ql (present) .
159.Fl q
160suppresses the read-time form.
161.Xr make 1
162itself typically warns later during a
163.Pa /usr/src
164build, when
165.Pa bsd.opts.mk
166.Pq or Pa src.opts.mk
167reloads
168.Pa bsd.mkopt.mk
169for recognized options such as
170.Va MANCOMPRESS .
171The same
172.Xr make.conf 5
173line stays silent for a bare
174.Xr make 1
175.Pq e.g. Fl C Pa /tmp
176or for ports, which do not run that option pass.
177.Ql WITHOUT_* Ns =no ,
178.Ql WITH_* Ns =NO ,
179and other values do not warn here or there.
180.Va WITHOUT_MODULES
181is not a presence knob
182.Pq its value is a module list
183and is excluded from
184.Fl s
185and presence display.
186.Pp
187For directives whose value is a space-separated list
188.Po
189.Va kld_list Ns -style ;
190see for example
191.Va kernels
192in
193.Xr loader.conf 5
194.Pc ,
195.Ar name Ns += Ns Ar word
196appends each given word not already present and
197.Ar name Ns -= Ns Ar word
198strikes each given word,
199after the fashion of
200.Xr sysrc 8 .
201Striking words from a directive set nowhere is reported like any other
202unknown directive.
203.Pp
204For
205.Xr make 1 Ns -syntax
206targets
207.Po
208.Cm make
209and
210.Cm src ;
211see
212.Xr sysconf-make 8
213and
214.Xr sysconf-src 8
215.Pc ,
216.Ql +=
217is instead the
218.Xr make 1
219append operator and
220.Ql -=
221strikes words from the last matching assignment fragment.
222.Pp
223Files are never modified in place:
224updates are streamed to a temporary file which is flushed to stable storage
225and atomically renamed over the target
226.Pq see Xr bsdconf_put 3 .
227How multi-file targets choose the file to read or rewrite is documented in
228.Xr sysconf-targets 8 .
229.Sh TARGETS
230The following target keywords are supported:
231.Bl -tag -width indent
232.It Cm loader
233Boot loader configuration
234.Pq Xr loader.conf 5 .
235See
236.Xr sysconf-loader 8 .
237.It Cm sysctl
238Kernel state set at boot
239.Pq Xr sysctl.conf 5 .
240See
241.Xr sysconf-sysctl 8 .
242.It Cm make
243System-wide
244.Xr make 1
245settings
246.Pq Pa /etc/make.conf .
247See
248.Xr sysconf-make 8 .
249.It Cm src
250The
251.Pa /usr/src
252build triad
253.Pq Pa src-env.conf , make.conf , src.conf .
254See
255.Xr sysconf-src 8 .
256.It Cm rc
257Pass-through to
258.Xr sysrc 8 .
259See
260.Xr sysconf-rc 8 .
261.It Cm generic
262Foreign or unknown format;
263requires
264.Fl f .
265See
266.Xr sysconf-generic 8 .
267.El
268.Pp
269Cross-cutting rules for multi-file sourcing,
270defaults,
271and where writes versus removals land are in
272.Xr sysconf-targets 8 .
273Built-in format descriptors and file-list discovery are in
274.Xr bsdconf_format 3 .
275.Sh OPTIONS
276The options are as follows:
277.Bl -tag -width indent
278.It Fl A
279Widen dump scope to include directives still at their system default
280.Po
281named reads always reflect the defaults;
282see
283.Xr sysconf-targets 8
284.Pc .
285With no
286.Ar name
287arguments,
288dumps everything
289.Po
290as
291.Fl a ,
292defaults included
293.Pc .
294.Pp
295Combined with
296.Fl D ,
297the scoping of
298.Fl D
299wins and
300.Fl A
301retains only its dump-implying role,
302so
303.Ql -ADd
304describes all defaults and only defaults,
305as in
306.Xr sysrc 8 .
307Only valid for targets with a defaults file
308.Pq see Xr sysconf-loader 8 .
309.It Fl a
310Dump all configured directives from the target:
311the union of the target's files,
312wherein directives in later files override earlier ones.
313Directives whose value still comes from the defaults file alone are out
314of scope
315.Pq widen with Fl A .
316.It Fl c
317Check mode.
318For each
319.Ar name Ns = Ns Ar value
320argument,
321compare the effective value against
322.Ar value
323without modifying any file
324.Po
325with
326.Fl x ,
327check that
328.Ar name
329is absent
330.Pc .
331Exit with success if no changes would be required,
332else error.
333.It Fl D
334Consult only the target's defaults file,
335reporting the system default value of each
336.Ar name
337.Po
338or, with
339.Fl a ,
340dumping every default
341.Pc .
342Defaults are read-only;
343combining
344.Fl D
345with an assignment is an error.
346Only valid for targets with a defaults file
347.Pq see Xr sysconf-loader 8 .
348.It Fl d
349Show the description of each
350.Ar name
351instead of its value.
352.Pp
353For targets with a defaults file,
354the description is the inline comment trailing the directive's default
355assignment,
356continued across subsequent lines of whitespace followed by a comment
357character.
358A commented-out default
359.Pq e.g., Ql #comconsole_speed=\(dq115200\(dq # Set the ...
360still yields its description.
361For the
362.Ql sysctl
363target,
364descriptions come from the running kernel
365.Po
366as with
367.Xr sysctl 8
368.Fl d ;
369see
370.Xr sysconf-sysctl 8
371.Pc .
372.Pp
373Combined with
374.Fl a ,
375.Fl A ,
376or
377.Fl D ,
378dumps the description of every directive in scope
379.Po
380of the configured directives,
381of everything defaults included,
382or of the defaults alone,
383respectively
384.Pc ,
385after the fashion of
386.Xr sysrc 8
387.Fl \&Ad .
388A directive the defaults never mention prints an empty description.
389.It Fl E
390With
391.Fl l
392or
393.Fl L ,
394list only files that exist on disk.
395.It Fl e
396Print values in
397.Ar name Ns = Ns Ar value
398format,
399suitable for feeding back into the configuration file.
400Applies to both reads and the informational echo from assignments
401.Po
402replacing the default
403.Ql name: value
404form;
405changed writes use
406.Ql name=old # -> new ,
407matching
408.Xr sysrc 8
409.Pc .
410For the
411.Ql loader
412target the value is quoted.
413.It Fl F
414Show the pathname of the file holding each directive's effective
415.Pq authoritative
416value instead of the value itself.
417For a directive still at its system default,
418this truthfully names the defaults file.
419.It Fl f Ar file
420Operate on
421.Ar file ,
422in the format of the
423.Ar target
424keyword,
425instead of the target's standard files;
426mutually exclusive with
427.Fl k .
428For read operations
429.Ar file
430may be a non-seekable stream
431.Po
432a fifo or
433.Pa /dev/stdin ,
434for example
435.Pc ;
436write operations require a regular file.
437A
438.Ar file
439of
440.Ql -
441means standard input
442.Pq a synonym for Pa /dev/stdin ,
443exempt from
444.Fl R .
445See
446.Xr sysconf-targets 8
447and
448.Xr sysconf-generic 8 .
449.It Fl h , Fl Fl help
450Print a short usage statement
451.Pq or, for the long form, the full option summary
452to stderr and exit.
453.It Fl Fl version
454Print
455.Nm
456and linked
457.Xr bsdconf 3
458versions and exit.
459.It Fl i
460Ignore unknown names
461.Pq and suppress the warning when writing an unknown sysctl OID .
462.It Fl j Ar jail
463Operate within the jail
464.Ar jail
465.Pq name or numeric id ;
466mutually exclusive with
467.Fl R .
468.It Fl k Ar module
469Include the kernel module drop-in file for
470.Ar module
471in the target's file list
472.Pq e.g., Pa /etc/sysctl.kld.d/ Ns Ar module Ns Pa .conf .
473Only valid for targets with a module drop-in directory
474.Pq see Xr sysconf-sysctl 8 .
475.It Fl l
476List the pathnames of the files backing the target,
477in sourcing order,
478and exit.
479The read-only defaults file is never listed
480.Po
481.Fl l
482enumerates only files
483.Nm sysconf
484may modify;
485see
486.Xr sysconf-targets 8
487.Pc .
488.It Fl L
489Like
490.Fl l ,
491but additionally list every drop-in candidate:
492for targets with a module drop-in directory,
493one candidate per loaded kernel module
494.Pq whether or not the file exists yet
495plus any drop-in already on disk.
496The read-only defaults file is likewise never listed.
497.It Fl n
498Show only directive values,
499not their names.
500.It Fl N
501Show only directive names,
502not their values.
503.It Fl q
504Quiet.
505Suppress warnings about unknown directives and the
506.Ql old -> new
507echo of write operations.
508.It Fl R Ar dir
509Operate within the root directory
510.Ar dir
511rather than
512.Pa / ;
513mutually exclusive with
514.Fl j .
515.It Fl s
516Set empty
517.Ql WITH_*
518and
519.Ql WITHOUT_*
520build knobs on the
521.Cm make
522and
523.Cm src
524targets
525.Po
526equivalent to
527.Ar name Ns =
528with no value;
529see
530.Xr sysconf-make 8
531and
532.Xr sysconf-src 8
533.Pc .
534Each bare
535.Ar name
536must begin with
537.Ql WITH_
538or
539.Ql WITHOUT_ .
540An already-present knob
541.Pq any value
542is left unchanged by
543.Fl s .
544An explicit
545.Ar name Ns =
546including empty always writes.
547Mutually exclusive with
548.Fl x .
549.It Fl v
550Verbose.
551Print the pathname of the configuration file holding the final effective
552value
553.Pq the last file in sourcing order that assigned the directive .
554.It Fl V
555Trail.
556For each named read
557.Pq and for Fl a ,
558print every assignment step that contributed to the effective value:
559.Ql file:line: nameopfragment ,
560and when the running effective value differs from the fragment,
561.Ql -> effective .
562.Pp
563For writes, print the same
564.Ql file:line:
565shape for the change:
566.Ql file:line: name=old -> name=new ,
567.Ql name=value (unchanged) ,
568.Ql name=value (added)
569when a new statement is created,
570or
571.Ql nameopfragment (removed)
572when a statement is deleted,
573using the statement operator
574.Ql = / += / ...
575as appropriate .
576.Pp
577Uses the same accumulation model as ordinary reads
578.Pq make(1) `+=' et al. ,
579so the last effective value matches
580.Fl v
581and,
582for linear conf files without
583.Ql .if ,
584.Nm make Fl V
585.Pq see Xr sysconf-make 8 and Xr sysconf-src 8 .
586.It Fl x
587Remove the named directive(s) from every file of the target listing them
588.Pq see Xr sysconf-targets 8 .
589With
590.Fl v
591or
592.Fl V ,
593a successful removal echoes
594.Ql name (removed)
595.Pq or a trail form with Fl V .
596.El
597.Sh ENVIRONMENT
598.Bl -tag -width "LOADER_DEFAULTS"
599.It Ev BSDCONF_MAX_BYTES
600Maximum bytes
601.Nm
602will read from a configuration file or stream;
603see
604.Xr bsdconf 3 .
605.It Ev LOADER_DEFAULTS
606Defaults file for the
607.Ql loader
608target;
609see
610.Xr sysconf-loader 8 .
611.It Ev SRC_ENV_CONF , Ev __MAKE_CONF , Ev SRCCONF
612Paths for the
613.Cm src
614triad;
615see
616.Xr sysconf-src 8 .
617.El
618.Sh FILES
619See the per-target manuals
620.Pq Xr sysconf-loader 8 , Xr sysconf-sysctl 8 , Xr sysconf-make 8 , Xr sysconf-src 8
621for the files each keyword consults.
622Common paths include
623.Pa /boot/loader.conf ,
624.Pa /etc/sysctl.conf ,
625.Pa /etc/make.conf ,
626and
627.Pa /etc/src.conf .
628.Sh EXIT STATUS
629.Ex -std
630In check mode
631.Pq Fl c ,
632an exit status of zero means no changes are required.
633.Sh EXAMPLES
634Read and set a boot loader directive:
635.Pp
636.Dl sysconf loader zfs_load
637.Dl sysconf loader zfs_load=\(dqYES\(dq
638.Pp
639Raise a sysctl applied at boot:
640.Pp
641.Dl sysconf sysctl kern.maxfiles=65536
642.Pp
643List files backing the loader target:
644.Pp
645.Dl sysconf loader -l
646.Pp
647Append to a space-separated list:
648.Pp
649.Dl sysconf loader kernels+=kernel_test
650.Pp
651Append a
652.Xr make 1
653flag and set a
654.Pa src.conf
655knob:
656.Pp
657.Dl sysconf make CFLAGS+=-DDEBUG
658.Dl sysconf src -s WITHOUT_LLDB
659.Dl sysconf src WITHOUT_LLDB=
660.Pp
661Further examples for each target appear in
662.Xr sysconf-loader 8 ,
663.Xr sysconf-sysctl 8 ,
664.Xr sysconf-make 8 ,
665.Xr sysconf-src 8 ,
666.Xr sysconf-rc 8 ,
667and
668.Xr sysconf-generic 8 .
669.Sh SEE ALSO
670.Xr bsdconf 3 ,
671.Xr bsdconf_format 3 ,
672.Xr bsdconf_put 3 ,
673.Xr loader.conf 5 ,
674.Xr src.conf 5 ,
675.Xr sysctl.conf 5 ,
676.Xr jail 8 ,
677.Xr sysconf-generic 8 ,
678.Xr sysconf-loader 8 ,
679.Xr sysconf-make 8 ,
680.Xr sysconf-rc 8 ,
681.Xr sysconf-src 8 ,
682.Xr sysconf-sysctl 8 ,
683.Xr sysconf-targets 8 ,
684.Xr sysctl 8 ,
685.Xr sysrc 8
686.Sh HISTORY
687The
688.Nm
689utility first appeared in
690.Fx 16.0 .
691.Sh AUTHORS
692.An Devin Teske Aq Mt dteske@FreeBSD.org
693.An Faraz Vahedi Aq Mt kfv@FreeBSD.org
694.Sh SECURITY CONSIDERATIONS
695Read-only invocations
696.Po
697including
698.Fl c
699checks, which never modify files
700.Pc
701run inside a
702.Xr capsicum 4
703sandbox:
704the backing files are opened first and the process then relinquishes all
705other capabilities before any file content is parsed.
706.Pp
707Write operations replace files atomically and never in place;
708see the
709.Sx SECURITY CONSIDERATIONS
710section of
711.Xr bsdconf_put 3
712for the properties of the write transaction.
713