xref: /freebsd/sbin/sysctl/sysctl.8 (revision c4da2cc9b39c919094f89bb5dab1110e56b7e250)
1dea673e9SRodney W. Grimes.\" Copyright (c) 1993
2dea673e9SRodney W. Grimes.\"	The Regents of the University of California.  All rights reserved.
3dea673e9SRodney W. Grimes.\"
4dea673e9SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without
5dea673e9SRodney W. Grimes.\" modification, are permitted provided that the following conditions
6dea673e9SRodney W. Grimes.\" are met:
7dea673e9SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright
8dea673e9SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer.
9dea673e9SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright
10dea673e9SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer in the
11dea673e9SRodney W. Grimes.\"    documentation and/or other materials provided with the distribution.
12dea673e9SRodney W. Grimes.\" 3. All advertising materials mentioning features or use of this software
13dea673e9SRodney W. Grimes.\"    must display the following acknowledgement:
14dea673e9SRodney W. Grimes.\"	This product includes software developed by the University of
15dea673e9SRodney W. Grimes.\"	California, Berkeley and its contributors.
16dea673e9SRodney W. Grimes.\" 4. Neither the name of the University nor the names of its contributors
17dea673e9SRodney W. Grimes.\"    may be used to endorse or promote products derived from this software
18dea673e9SRodney W. Grimes.\"    without specific prior written permission.
19dea673e9SRodney W. Grimes.\"
20dea673e9SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21dea673e9SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22dea673e9SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23dea673e9SRodney W. Grimes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24dea673e9SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25dea673e9SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26dea673e9SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27dea673e9SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28dea673e9SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29dea673e9SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30dea673e9SRodney W. Grimes.\" SUCH DAMAGE.
31dea673e9SRodney W. Grimes.\"
328e3847b2SGarrett Wollman.\"	From: @(#)sysctl.8	8.1 (Berkeley) 6/6/93
337f3dea24SPeter Wemm.\" $FreeBSD$
34dea673e9SRodney W. Grimes.\"
35c4da2cc9SDima Dorfman.Dd May 28, 2001
36dea673e9SRodney W. Grimes.Dt SYSCTL 8
37dea673e9SRodney W. Grimes.Os
38dea673e9SRodney W. Grimes.Sh NAME
39dea673e9SRodney W. Grimes.Nm sysctl
40dea673e9SRodney W. Grimes.Nd get or set kernel state
41dea673e9SRodney W. Grimes.Sh SYNOPSIS
427c7fb079SRuslan Ermilov.Nm
439a2402bcSDag-Erling Smørgrav.Op Fl bNnox
449a2402bcSDag-Erling Smørgrav.Ar name Ns Op = Ns Ar value
459a2402bcSDag-Erling Smørgrav.Ar ...
467c7fb079SRuslan Ermilov.Nm
479a2402bcSDag-Erling Smørgrav.Op Fl bNnox
489a2402bcSDag-Erling Smørgrav.Fl a
49dea673e9SRodney W. Grimes.Sh DESCRIPTION
50dea673e9SRodney W. GrimesThe
51d9b1bc77SPhilippe Charnier.Nm
529a2402bcSDag-Erling Smørgravutility retrieves kernel state and allows processes with appropriate
539a2402bcSDag-Erling Smørgravprivilege to set kernel state.
549a2402bcSDag-Erling SmørgravThe state to be retrieved or set is described using a ``Management
559a2402bcSDag-Erling SmørgravInformation Base'' (``MIB'') style name, described as a dotted set of
569a2402bcSDag-Erling Smørgravcomponents.
571d86b91cSPoul-Henning Kamp.Pp
58d9b1bc77SPhilippe CharnierThe following options are available:
59d9b1bc77SPhilippe Charnier.Bl -tag -width indent
60d9b1bc77SPhilippe Charnier.It Fl A
619a2402bcSDag-Erling SmørgravEquivalent to
629a2402bcSDag-Erling Smørgrav.Fl o
63dea673e9SRodney W. Grimes.Fl a
649a2402bcSDag-Erling Smørgrav(for compatibility).
659a2402bcSDag-Erling Smørgrav.It Fl a
669a2402bcSDag-Erling SmørgravList all the currently available non-opaque values.
679a2402bcSDag-Erling SmørgravThis option is ignored if one or more variable names are specified on
689a2402bcSDag-Erling Smørgravthe command line.
69c4da2cc9SDima Dorfman.It Fl b
70c4da2cc9SDima DorfmanForce the value of the variable(s) to be output in raw, binary format.
71c4da2cc9SDima DorfmanNo names are printed and no terminating newlines are output.
72c4da2cc9SDima DorfmanThis is mostly useful with a single variable.
730ef56fd8SDag-Erling Smørgrav.It Fl N
740ef56fd8SDag-Erling SmørgravShow only variable names, not their values.
759a2402bcSDag-Erling SmørgravThis is particularly useful with shells that offer programmable
769a2402bcSDag-Erling Smørgravcompletion.
779a2402bcSDag-Erling SmørgravTo enable completion of variable names in
789a2402bcSDag-Erling Smørgrav.Nm zsh ,
799a2402bcSDag-Erling Smørgravuse the following code:
809a2402bcSDag-Erling Smørgrav.Bd -literal -offset indent -compact
819a2402bcSDag-Erling Smørgravlistsysctls () { set -A reply $(sysctl -AN ${1%.*}) }
829a2402bcSDag-Erling Smørgravcompctl -K listsysctls sysctl
839a2402bcSDag-Erling Smørgrav.Ed
84d9b1bc77SPhilippe Charnier.It Fl n
859a2402bcSDag-Erling SmørgravShow only variable values, not their names.
869a2402bcSDag-Erling SmørgravThis option is useful for setting shell variables.
879a2402bcSDag-Erling SmørgravFor instance, to save the pagesize in variable psize, use:
88dea673e9SRodney W. Grimes.Bd -literal -offset indent -compact
89dea673e9SRodney W. Grimesset psize=`sysctl -n hw.pagesize`
90dea673e9SRodney W. Grimes.Ed
91c4da2cc9SDima Dorfman.It Fl o
929a2402bcSDag-Erling SmørgravShow opaque variables (which are normally suppressed).
939a2402bcSDag-Erling SmørgravThe format and length are printed, as well as a hex dump of the first
949a2402bcSDag-Erling Smørgravsixteen bytes of the value.
959a2402bcSDag-Erling Smørgrav.It Fl X
969a2402bcSDag-Erling SmørgravEquivalent to
979a2402bcSDag-Erling Smørgrav.Fl x
989a2402bcSDag-Erling Smørgrav.Fl a
999a2402bcSDag-Erling Smørgrav(for compatibility).
1009a2402bcSDag-Erling Smørgrav.It Fl x
1019a2402bcSDag-Erling SmørgravAs
1029a2402bcSDag-Erling Smørgrav.Fl o ,
1039a2402bcSDag-Erling Smørgravbut prints a hex dump of the entire value instead of just the first
1049a2402bcSDag-Erling Smørgravfew bytes.
105d9b1bc77SPhilippe Charnier.El
106dea673e9SRodney W. Grimes.Pp
107dea673e9SRodney W. GrimesThe information available from
108d9b1bc77SPhilippe Charnier.Nm
1091d86b91cSPoul-Henning Kampconsists of integers, strings, and opaques.
110d9b1bc77SPhilippe Charnier.Nm Sysctl
1111d86b91cSPoul-Henning Kamponly knows about a couple of opaque types, and will resort to hexdumps
1121d86b91cSPoul-Henning Kampfor the rest.
1131d86b91cSPoul-Henning KampThe opaque information is much more useful if retrieved by special
114dea673e9SRodney W. Grimespurpose programs such as
115dea673e9SRodney W. Grimes.Nm ps ,
116dea673e9SRodney W. Grimes.Nm systat ,
117dea673e9SRodney W. Grimesand
118dea673e9SRodney W. Grimes.Nm netstat .
1191d86b91cSPoul-Henning Kamp.Pp
1204a8d0283SMike PritchardThe string and integer information is summarized below.
121dea673e9SRodney W. GrimesFor a detailed description of these variable see
122dea673e9SRodney W. Grimes.Xr sysctl 3 .
1231d86b91cSPoul-Henning Kamp.Pp
124dea673e9SRodney W. GrimesThe changeable column indicates whether a process with appropriate
125dea673e9SRodney W. Grimesprivilege can change the value.
126dea673e9SRodney W. Grimes.Bl -column net.inet.ip.forwardingxxxxxx integerxxx
127d8aa002eSRuslan Ermilov.It Sy "Name	Type	Changeable
128d8aa002eSRuslan Ermilov.It "kern.ostype	string	no
129d8aa002eSRuslan Ermilov.It "kern.osrelease	string	no
130d8aa002eSRuslan Ermilov.It "kern.osrevision	integer	no
131d8aa002eSRuslan Ermilov.It "kern.version	string	no
132d8aa002eSRuslan Ermilov.It "kern.maxvnodes	integer	yes
133d8aa002eSRuslan Ermilov.It "kern.maxproc	integer	no
134d8aa002eSRuslan Ermilov.It "kern.maxprocperuid	integer	yes
135d8aa002eSRuslan Ermilov.It "kern.maxfiles	integer	yes
136d8aa002eSRuslan Ermilov.It "kern.maxfilesperproc	integer	yes
137d8aa002eSRuslan Ermilov.It "kern.argmax	integer	no
138d8aa002eSRuslan Ermilov.It "kern.suser_permitted	integer	yes
139d8aa002eSRuslan Ermilov.It "kern.securelevel	integer	raise only
140d8aa002eSRuslan Ermilov.It "kern.hostname	string	yes
141d8aa002eSRuslan Ermilov.It "kern.hostid	integer	yes
142d8aa002eSRuslan Ermilov.It "kern.clockrate	struct	no
143d8aa002eSRuslan Ermilov.It "kern.posix1version	integer	no
144d8aa002eSRuslan Ermilov.It "kern.ngroups	integer	no
145d8aa002eSRuslan Ermilov.It "kern.job_control	integer	no
146d8aa002eSRuslan Ermilov.It "kern.saved_ids	integer	no
147d8aa002eSRuslan Ermilov.It "kern.boottime	struct	no
148d8aa002eSRuslan Ermilov.It "kern.domainname	string	yes
149d8aa002eSRuslan Ermilov.It "kern.filedelay	integer	yes
150d8aa002eSRuslan Ermilov.It "kern.dirdelay	integer	yes
151d8aa002eSRuslan Ermilov.It "kern.metadelay	integer	yes
152d8aa002eSRuslan Ermilov.It "kern.osreldate	string	no
153d8aa002eSRuslan Ermilov.It "kern.bootfile	string	yes
154d8aa002eSRuslan Ermilov.It "kern.corefile	string	yes
155d8aa002eSRuslan Ermilov.It "kern.logsigexit	integer	yes
156d8aa002eSRuslan Ermilov.It "vm.loadavg	struct	no
157d8aa002eSRuslan Ermilov.It "hw.machine	string	no
158d8aa002eSRuslan Ermilov.It "hw.model	string	no
159d8aa002eSRuslan Ermilov.It "hw.ncpu	integer	no
160d8aa002eSRuslan Ermilov.It "hw.byteorder	integer	no
161d8aa002eSRuslan Ermilov.It "hw.physmem	integer	no
162d8aa002eSRuslan Ermilov.It "hw.usermem	integer	no
163d8aa002eSRuslan Ermilov.It "hw.pagesize	integer	no
164d8aa002eSRuslan Ermilov.It "hw.floatingpoint	integer	no
165d8aa002eSRuslan Ermilov.It "hw.machine_arch	string	no
166d8aa002eSRuslan Ermilov.It "machdep.console_device	dev_t	no
167d8aa002eSRuslan Ermilov.It "machdep.adjkerntz	integer	yes
168d8aa002eSRuslan Ermilov.It "machdep.disable_rtc_set	integer	yes
169d8aa002eSRuslan Ermilov.It "user.cs_path	string	no
170d8aa002eSRuslan Ermilov.It "user.bc_base_max	integer	no
171d8aa002eSRuslan Ermilov.It "user.bc_dim_max	integer	no
172d8aa002eSRuslan Ermilov.It "user.bc_scale_max	integer	no
173d8aa002eSRuslan Ermilov.It "user.bc_string_max	integer	no
174d8aa002eSRuslan Ermilov.It "user.coll_weights_max	integer	no
175d8aa002eSRuslan Ermilov.It "user.expr_nest_max	integer	no
176d8aa002eSRuslan Ermilov.It "user.line_max	integer	no
177d8aa002eSRuslan Ermilov.It "user.re_dup_max	integer	no
178d8aa002eSRuslan Ermilov.It "user.posix2_version	integer	no
179d8aa002eSRuslan Ermilov.It "user.posix2_c_bind	integer	no
180d8aa002eSRuslan Ermilov.It "user.posix2_c_dev	integer	no
181d8aa002eSRuslan Ermilov.It "user.posix2_char_term	integer	no
182d8aa002eSRuslan Ermilov.It "user.posix2_fort_dev	integer	no
183d8aa002eSRuslan Ermilov.It "user.posix2_fort_run	integer	no
184d8aa002eSRuslan Ermilov.It "user.posix2_localedef	integer	no
185d8aa002eSRuslan Ermilov.It "user.posix2_sw_dev	integer	no
186d8aa002eSRuslan Ermilov.It "user.posix2_upe	integer	no
187d8aa002eSRuslan Ermilov.It "user.stream_max	integer	no
188d8aa002eSRuslan Ermilov.It "user.tzname_max	integer	no
189dea673e9SRodney W. Grimes.El
190dea673e9SRodney W. Grimes.Sh EXAMPLES
191dea673e9SRodney W. GrimesFor example, to retrieve the maximum number of processes allowed
192b91e5f67SSteve Pricein the system, one would use the following request:
193dea673e9SRodney W. Grimes.Bd -literal -offset indent -compact
194dea673e9SRodney W. Grimessysctl kern.maxproc
195dea673e9SRodney W. Grimes.Ed
196dea673e9SRodney W. Grimes.Pp
197dea673e9SRodney W. GrimesTo set the maximum number of processes allowed
198b91e5f67SSteve Priceper uid to 1000, one would use the following request:
199dea673e9SRodney W. Grimes.Bd -literal -offset indent -compact
2001c4d6295SJoseph Koshysysctl -w kern.maxprocperuid=1000
201dea673e9SRodney W. Grimes.Ed
202dea673e9SRodney W. Grimes.Pp
203dea673e9SRodney W. GrimesInformation about the system clock rate may be obtained with:
204dea673e9SRodney W. Grimes.Bd -literal -offset indent -compact
205dea673e9SRodney W. Grimessysctl kern.clockrate
206dea673e9SRodney W. Grimes.Ed
207dea673e9SRodney W. Grimes.Pp
208d9b1bc77SPhilippe CharnierInformation about the load average history may be obtained with:
209dea673e9SRodney W. Grimes.Bd -literal -offset indent -compact
210dea673e9SRodney W. Grimessysctl vm.loadavg
211dea673e9SRodney W. Grimes.Ed
2121d86b91cSPoul-Henning Kamp.Pp
2131d86b91cSPoul-Henning KampMore variables than these exist, and the best and likely only place
2141d86b91cSPoul-Henning Kampto search for their deeper meaning is undoubtedly the source where
2151d86b91cSPoul-Henning Kampthey are defined.
216dea673e9SRodney W. Grimes.Sh FILES
217dea673e9SRodney W. Grimes.Bl -tag -width <netinet/icmpXvar.h> -compact
218dea673e9SRodney W. Grimes.It Pa <sys/sysctl.h>
219dea673e9SRodney W. Grimesdefinitions for top level identifiers, second level kernel and hardware
220dea673e9SRodney W. Grimesidentifiers, and user level identifiers
221dea673e9SRodney W. Grimes.It Pa <sys/socket.h>
222dea673e9SRodney W. Grimesdefinitions for second level network identifiers
223dea673e9SRodney W. Grimes.It Pa <sys/gmon.h>
224dea673e9SRodney W. Grimesdefinitions for third level profiling identifiers
225dea673e9SRodney W. Grimes.It Pa <vm/vm_param.h>
226dea673e9SRodney W. Grimesdefinitions for second level virtual memory identifiers
227dea673e9SRodney W. Grimes.It Pa <netinet/in.h>
228dea673e9SRodney W. Grimesdefinitions for third level Internet identifiers and
229dea673e9SRodney W. Grimesfourth level IP identifiers
230dea673e9SRodney W. Grimes.It Pa <netinet/icmp_var.h>
231dea673e9SRodney W. Grimesdefinitions for fourth level ICMP identifiers
232dea673e9SRodney W. Grimes.It Pa <netinet/udp_var.h>
233dea673e9SRodney W. Grimesdefinitions for fourth level UDP identifiers
234dea673e9SRodney W. Grimes.El
235dea673e9SRodney W. Grimes.Sh SEE ALSO
23697a00e76SAlexey Zelkin.Xr sysctl 3 ,
23797a00e76SAlexey Zelkin.Xr blackhole 4 ,
2382cd4f9e1SDavid E. O'Brien.Xr sysctl.conf 5
2391d86b91cSPoul-Henning Kamp.Sh BUGS
240d9b1bc77SPhilippe Charnier.Nm Sysctl
2411d86b91cSPoul-Henning Kamppresently exploits an undocumented interface to the kernel
2424a8d0283SMike Pritchardsysctl facility to traverse the sysctl tree and to retrieve format
2431d86b91cSPoul-Henning Kampand name information.
2441d86b91cSPoul-Henning KampThis correct interface is being thought about for the time being.
245dea673e9SRodney W. Grimes.Sh HISTORY
246d9b1bc77SPhilippe Charnier.Nm Sysctl
24785cf659aSMike Pritchardfirst appeared in
24885cf659aSMike Pritchard.Bx 4.4 .
2491d86b91cSPoul-Henning Kamp.Pp
25085cf659aSMike PritchardIn
251d9b1bc77SPhilippe Charnier.Fx 2.2 ,
252d9b1bc77SPhilippe Charnier.Nm
25385cf659aSMike Pritchardwas significantly remodeled.
254