xref: /dragonfly/sbin/sysctl/sysctl.8 (revision 1de703da)
1.\" Copyright (c) 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
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.
12.\" 3. All advertising materials mentioning features or use of this software
13.\"    must display the following acknowledgement:
14.\"	This product includes software developed by the University of
15.\"	California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\"    may be used to endorse or promote products derived from this software
18.\"    without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\"	From: @(#)sysctl.8	8.1 (Berkeley) 6/6/93
33.\" $FreeBSD: src/sbin/sysctl/sysctl.8,v 1.23.2.17 2003/05/19 07:49:34 brueffer Exp $
34.\" $DragonFly: src/sbin/sysctl/sysctl.8,v 1.2 2003/06/17 04:27:34 dillon Exp $
35.\"
36.Dd March 10, 2002
37.Dt SYSCTL 8
38.Os
39.Sh NAME
40.Nm sysctl
41.Nd get or set kernel state
42.Sh SYNOPSIS
43.Nm
44.Op Fl bdeNnox
45.Ar name Ns Op = Ns Ar value
46.Ar ...
47.Nm
48.Op Fl bdeNnox
49.Fl a
50.Sh DESCRIPTION
51The
52.Nm
53utility retrieves kernel state and allows processes with appropriate
54privilege to set kernel state.
55The state to be retrieved or set is described using a
56.Dq Management Information Base
57.Pq Dq MIB
58style name, described as a dotted set of
59components.
60.Pp
61The following options are available:
62.Bl -tag -width indent
63.It Fl A
64Equivalent to
65.Fl o a
66(for compatibility).
67.It Fl a
68List all the currently available non-opaque values.
69This option is ignored if one or more variable names are specified on
70the command line.
71.It Fl b
72Force the value of the variable(s) to be output in raw, binary format.
73No names are printed and no terminating newlines are output.
74This is mostly useful with a single variable.
75.It Fl d
76Print the description of the variable instead of its value.
77.It Fl e
78Separate the name and the value of the variable(s) with
79.Ql = .
80This is useful for producing output which can be fed back to the
81.Nm
82utility.
83This option is ignored if either
84.Fl N
85or
86.Fl n
87is specified, or a variable is being set.
88.It Fl N
89Show only variable names, not their values.
90This is particularly useful with shells that offer programmable
91completion.
92To enable completion of variable names in
93.Nm zsh ,
94use the following code:
95.Bd -literal -offset indent
96listsysctls () { set -A reply $(sysctl -AN ${1%.*}) }
97compctl -K listsysctls sysctl
98.Ed
99.It Fl n
100Show only variable values, not their names.
101This option is useful for setting shell variables.
102For instance, to save the pagesize in variable
103.Va psize ,
104use:
105.Pp
106.Dl "set psize=`sysctl -n hw.pagesize`"
107.It Fl o
108Show opaque variables (which are normally suppressed).
109The format and length are printed, as well as a hex dump of the first
110sixteen bytes of the value.
111.It Fl X
112Equivalent to
113.Fl x a
114(for compatibility).
115.It Fl x
116As
117.Fl o ,
118but prints a hex dump of the entire value instead of just the first
119few bytes.
120.El
121.Pp
122The information available from
123.Nm
124consists of integers, strings, devices
125.Pq Vt dev_t ,
126and opaque types.
127The
128.Nm
129utility
130only knows about a couple of opaque types, and will resort to hexdumps
131for the rest.
132The opaque information is much more useful if retrieved by special
133purpose programs such as
134.Nm ps , systat ,
135and
136.Nm netstat .
137.Pp
138Some of the variables which cannot be modified during normal system
139operation can be initialized via
140.Xr loader 8
141tunables.
142This can for example be done by setting them in
143.Xr loader.conf 5 .
144Please refer to
145.Xr loader.conf 5
146for more information on which tunables are available and how to set them.
147.Pp
148The string and integer information is summarized below.
149For a detailed description of these variable see
150.Xr sysctl 3 .
151.Pp
152The changeable column indicates whether a process with appropriate
153privilege can change the value.
154String, integer, and devices values can be set using
155.Nm .
156For device values,
157.Cm value
158can be specified as a character device special file name.
159Special values
160.Cm off
161and
162.Ar none
163denote
164.Dq no device .
165.Bl -column net.inet.ip.forwardingxxxxxx integerxxx
166.It Sy "Name	Type	Changeable
167.It "kern.ostype	string	no
168.It "kern.osrelease	string	no
169.It "kern.osrevision	integer	no
170.It "kern.version	string	no
171.It "kern.maxvnodes	integer	yes
172.It "kern.maxproc	integer	no
173.It "kern.maxprocperuid	integer	yes
174.It "kern.maxfiles	integer	yes
175.It "kern.maxfilesperproc	integer	yes
176.It "kern.argmax	integer	no
177.It "kern.securelevel	integer	raise only
178.It "kern.hostname	string	yes
179.It "kern.hostid	integer	yes
180.It "kern.clockrate	struct	no
181.It "kern.posix1version	integer	no
182.It "kern.ngroups	integer	no
183.It "kern.job_control	integer	no
184.It "kern.saved_ids	integer	no
185.It "kern.boottime	struct	no
186.It "kern.domainname	string	yes
187.It "kern.filedelay	integer	yes
188.It "kern.dirdelay	integer	yes
189.It "kern.metadelay	integer	yes
190.It "kern.osreldate	string	no
191.It "kern.bootfile	string	yes
192.It "kern.corefile	string	yes
193.It "kern.dumpdev	dev_t	yes
194.It "kern.logsigexit	integer	yes
195.It "vm.loadavg	struct	no
196.It "hw.machine	string	no
197.It "hw.model	string	no
198.It "hw.ncpu	integer	no
199.It "hw.byteorder	integer	no
200.It "hw.physmem	integer	no
201.It "hw.usermem	integer	no
202.It "hw.pagesize	integer	no
203.It "hw.floatingpoint	integer	no
204.It "hw.machine_arch	string	no
205.It "machdep.console_device	dev_t	no
206.It "machdep.adjkerntz	integer	yes
207.It "machdep.disable_rtc_set	integer	yes
208.It "user.cs_path	string	no
209.It "user.bc_base_max	integer	no
210.It "user.bc_dim_max	integer	no
211.It "user.bc_scale_max	integer	no
212.It "user.bc_string_max	integer	no
213.It "user.coll_weights_max	integer	no
214.It "user.expr_nest_max	integer	no
215.It "user.line_max	integer	no
216.It "user.re_dup_max	integer	no
217.It "user.posix2_version	integer	no
218.It "user.posix2_c_bind	integer	no
219.It "user.posix2_c_dev	integer	no
220.It "user.posix2_char_term	integer	no
221.It "user.posix2_fort_dev	integer	no
222.It "user.posix2_fort_run	integer	no
223.It "user.posix2_localedef	integer	no
224.It "user.posix2_sw_dev	integer	no
225.It "user.posix2_upe	integer	no
226.It "user.stream_max	integer	no
227.It "user.tzname_max	integer	no
228.El
229.Sh EXAMPLES
230For example, to retrieve the maximum number of processes allowed
231in the system, one would use the following request:
232.Pp
233.Dl "sysctl kern.maxproc"
234.Pp
235To set the maximum number of processes allowed
236per uid to 1000, one would use the following request:
237.Pp
238.Dl "sysctl kern.maxprocperuid=1000"
239.Pp
240The device used for crash dumps can be specified using:
241.Pp
242.Dl "sysctl kern.dumpdev=/dev/somedev"
243.Pp
244which is equivalent to
245.Pp
246.Dl "dumpon /dev/somedev"
247.Pp
248Information about the system clock rate may be obtained with:
249.Pp
250.Dl "sysctl kern.clockrate"
251.Pp
252Information about the load average history may be obtained with:
253.Pp
254.Dl "sysctl vm.loadavg"
255.Pp
256More variables than these exist, and the best and likely only place
257to search for their deeper meaning is undoubtedly the source where
258they are defined.
259.Sh FILES
260.Bl -tag -width ".Aq Pa netinet/icmp_var.h" -compact
261.It Aq Pa sys/sysctl.h
262definitions for top level identifiers, second level kernel and hardware
263identifiers, and user level identifiers
264.It Aq Pa sys/socket.h
265definitions for second level network identifiers
266.It Aq Pa sys/gmon.h
267definitions for third level profiling identifiers
268.It Aq Pa vm/vm_param.h
269definitions for second level virtual memory identifiers
270.It Aq Pa netinet/in.h
271definitions for third level Internet identifiers and
272fourth level IP identifiers
273.It Aq Pa netinet/icmp_var.h
274definitions for fourth level ICMP identifiers
275.It Aq Pa netinet/udp_var.h
276definitions for fourth level UDP identifiers
277.El
278.Sh COMPATIBILITY
279The
280.Fl w
281option has been deprecated and is silently ignored.
282.Sh SEE ALSO
283.Xr sysctl 3 ,
284.Xr loader.conf 5 ,
285.Xr sysctl.conf 5 ,
286.Xr loader 8
287.Sh BUGS
288The
289.Nm
290utility presently exploits an undocumented interface to the kernel
291sysctl facility to traverse the sysctl tree and to retrieve format
292and name information.
293This correct interface is being thought about for the time being.
294.Sh HISTORY
295A
296.Nm
297utility first appeared in
298.Bx 4.4 .
299.Pp
300In
301.Fx 2.2 ,
302.Nm
303was significantly remodeled.
304