xref: /freebsd/sbin/sysctl/sysctl.8 (revision f93d36fd9232ce878aa8df6fa10fedecf218fb34)
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.\" 4. Neither the name of the University nor the names of its contributors
13dea673e9SRodney W. Grimes.\"    may be used to endorse or promote products derived from this software
14dea673e9SRodney W. Grimes.\"    without specific prior written permission.
15dea673e9SRodney W. Grimes.\"
16dea673e9SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17dea673e9SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18dea673e9SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19dea673e9SRodney W. Grimes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20dea673e9SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21dea673e9SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22dea673e9SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23dea673e9SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24dea673e9SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25dea673e9SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26dea673e9SRodney W. Grimes.\" SUCH DAMAGE.
27dea673e9SRodney W. Grimes.\"
288e3847b2SGarrett Wollman.\"	From: @(#)sysctl.8	8.1 (Berkeley) 6/6/93
297f3dea24SPeter Wemm.\" $FreeBSD$
30dea673e9SRodney W. Grimes.\"
3142277d47SDima Dorfman.Dd March 10, 2002
32dea673e9SRodney W. Grimes.Dt SYSCTL 8
33dea673e9SRodney W. Grimes.Os
34dea673e9SRodney W. Grimes.Sh NAME
35dea673e9SRodney W. Grimes.Nm sysctl
36dea673e9SRodney W. Grimes.Nd get or set kernel state
37dea673e9SRodney W. Grimes.Sh SYNOPSIS
387c7fb079SRuslan Ermilov.Nm
397434ec74SDag-Erling Smørgrav.Op Fl bdehNnox
409a2402bcSDag-Erling Smørgrav.Ar name Ns Op = Ns Ar value
419a2402bcSDag-Erling Smørgrav.Ar ...
427c7fb079SRuslan Ermilov.Nm
43f93d36fdSRobert Watson.Op Fl bdehNnoqx
449a2402bcSDag-Erling Smørgrav.Fl a
45dea673e9SRodney W. Grimes.Sh DESCRIPTION
46dea673e9SRodney W. GrimesThe
47d9b1bc77SPhilippe Charnier.Nm
489a2402bcSDag-Erling Smørgravutility retrieves kernel state and allows processes with appropriate
499a2402bcSDag-Erling Smørgravprivilege to set kernel state.
50def778b8SRuslan ErmilovThe state to be retrieved or set is described using a
51def778b8SRuslan Ermilov.Dq Management Information Base
52def778b8SRuslan Ermilov.Pq Dq MIB
53def778b8SRuslan Ermilovstyle name, described as a dotted set of
549a2402bcSDag-Erling Smørgravcomponents.
551d86b91cSPoul-Henning Kamp.Pp
56d9b1bc77SPhilippe CharnierThe following options are available:
57d9b1bc77SPhilippe Charnier.Bl -tag -width indent
58d9b1bc77SPhilippe Charnier.It Fl A
599a2402bcSDag-Erling SmørgravEquivalent to
60def778b8SRuslan Ermilov.Fl o a
619a2402bcSDag-Erling Smørgrav(for compatibility).
629a2402bcSDag-Erling Smørgrav.It Fl a
639a2402bcSDag-Erling SmørgravList all the currently available non-opaque values.
649a2402bcSDag-Erling SmørgravThis option is ignored if one or more variable names are specified on
659a2402bcSDag-Erling Smørgravthe command line.
66c4da2cc9SDima Dorfman.It Fl b
67c4da2cc9SDima DorfmanForce the value of the variable(s) to be output in raw, binary format.
68c4da2cc9SDima DorfmanNo names are printed and no terminating newlines are output.
69c4da2cc9SDima DorfmanThis is mostly useful with a single variable.
706105f815SLuigi Rizzo.It Fl d
716105f815SLuigi RizzoPrint the description of the variable instead of its value.
72d0b8aabbSAnton Berezin.It Fl e
7328dc1d23SAnton BerezinSeparate the name and the value of the variable(s) with
7428dc1d23SAnton Berezin.Ql = .
75d0b8aabbSAnton BerezinThis is useful for producing output which can be fed back to the
76d0b8aabbSAnton Berezin.Nm
77d0b8aabbSAnton Berezinutility.
78d0b8aabbSAnton BerezinThis option is ignored if either
79d0b8aabbSAnton Berezin.Fl N
80d0b8aabbSAnton Berezinor
81d0b8aabbSAnton Berezin.Fl n
82d0b8aabbSAnton Berezinis specified, or a variable is being set.
8345817aaaSDag-Erling Smørgrav.It Fl h
8445817aaaSDag-Erling SmørgravFormat output for human, rather than machine, readability.
850ef56fd8SDag-Erling Smørgrav.It Fl N
860ef56fd8SDag-Erling SmørgravShow only variable names, not their values.
879a2402bcSDag-Erling SmørgravThis is particularly useful with shells that offer programmable
889a2402bcSDag-Erling Smørgravcompletion.
899a2402bcSDag-Erling SmørgravTo enable completion of variable names in
90f0ea72a0SChristian Brueffer.Xr zsh 1 Pq Pa ports/shells/zsh ,
919a2402bcSDag-Erling Smørgravuse the following code:
92def778b8SRuslan Ermilov.Bd -literal -offset indent
939a2402bcSDag-Erling Smørgravlistsysctls () { set -A reply $(sysctl -AN ${1%.*}) }
949a2402bcSDag-Erling Smørgravcompctl -K listsysctls sysctl
959a2402bcSDag-Erling Smørgrav.Ed
96ec3724d9SHiten Pandya.Pp
97ec3724d9SHiten PandyaTo enable completion of variable names in
98ec3724d9SHiten Pandya.Xr tcsh 1 ,
99ec3724d9SHiten Pandyause:
10021414470SRuslan Ermilov.Pp
10121414470SRuslan Ermilov.Dl "complete sysctl 'n/*/`sysctl -Na`/'"
102d9b1bc77SPhilippe Charnier.It Fl n
1039a2402bcSDag-Erling SmørgravShow only variable values, not their names.
1049a2402bcSDag-Erling SmørgravThis option is useful for setting shell variables.
105def778b8SRuslan ErmilovFor instance, to save the pagesize in variable
106def778b8SRuslan Ermilov.Va psize ,
107def778b8SRuslan Ermilovuse:
108def778b8SRuslan Ermilov.Pp
109def778b8SRuslan Ermilov.Dl "set psize=`sysctl -n hw.pagesize`"
110c4da2cc9SDima Dorfman.It Fl o
1119a2402bcSDag-Erling SmørgravShow opaque variables (which are normally suppressed).
1129a2402bcSDag-Erling SmørgravThe format and length are printed, as well as a hex dump of the first
1139a2402bcSDag-Erling Smørgravsixteen bytes of the value.
114f93d36fdSRobert Watson.It Fl q
115f93d36fdSRobert WatsonSuppress some warnings generated by
116f93d36fdSRobert Watson.Nm
117f93d36fdSRobert Watsonto standard error.
1189a2402bcSDag-Erling Smørgrav.It Fl X
1199a2402bcSDag-Erling SmørgravEquivalent to
120def778b8SRuslan Ermilov.Fl x a
1219a2402bcSDag-Erling Smørgrav(for compatibility).
1229a2402bcSDag-Erling Smørgrav.It Fl x
1239a2402bcSDag-Erling SmørgravAs
1249a2402bcSDag-Erling Smørgrav.Fl o ,
1259a2402bcSDag-Erling Smørgravbut prints a hex dump of the entire value instead of just the first
1269a2402bcSDag-Erling Smørgravfew bytes.
127d9b1bc77SPhilippe Charnier.El
128dea673e9SRodney W. Grimes.Pp
129dea673e9SRodney W. GrimesThe information available from
130d9b1bc77SPhilippe Charnier.Nm
13142277d47SDima Dorfmanconsists of integers, strings, devices
13242277d47SDima Dorfman.Pq Vt dev_t ,
13342277d47SDima Dorfmanand opaque types.
134629e80efSPhilippe CharnierThe
135629e80efSPhilippe Charnier.Nm
136629e80efSPhilippe Charnierutility
1371d86b91cSPoul-Henning Kamponly knows about a couple of opaque types, and will resort to hexdumps
1381d86b91cSPoul-Henning Kampfor the rest.
1391d86b91cSPoul-Henning KampThe opaque information is much more useful if retrieved by special
140dea673e9SRodney W. Grimespurpose programs such as
1414f898f94SPhilippe Charnier.Xr ps 1 ,
1424f898f94SPhilippe Charnier.Xr systat 1 ,
143dea673e9SRodney W. Grimesand
1444f898f94SPhilippe Charnier.Xr netstat 1 .
1451d86b91cSPoul-Henning Kamp.Pp
14643308797SChristian BruefferSome of the variables which cannot be modified during normal system
147ab5e6ef0SChristian Bruefferoperation can be initialized via
148ab5e6ef0SChristian Brueffer.Xr loader 8
149ab5e6ef0SChristian Brueffertunables.
150ab5e6ef0SChristian BruefferThis can for example be done by setting them in
15143308797SChristian Brueffer.Xr loader.conf 5 .
152ab5e6ef0SChristian BruefferPlease refer to
153ab5e6ef0SChristian Brueffer.Xr loader.conf 5
154ab5e6ef0SChristian Bruefferfor more information on which tunables are available and how to set them.
15543308797SChristian Brueffer.Pp
1564a8d0283SMike PritchardThe string and integer information is summarized below.
157dea673e9SRodney W. GrimesFor a detailed description of these variable see
158dea673e9SRodney W. Grimes.Xr sysctl 3 .
1591d86b91cSPoul-Henning Kamp.Pp
160dea673e9SRodney W. GrimesThe changeable column indicates whether a process with appropriate
161dea673e9SRodney W. Grimesprivilege can change the value.
16242277d47SDima DorfmanString, integer, and devices values can be set using
16342277d47SDima Dorfman.Nm .
16442277d47SDima DorfmanFor device values,
16542277d47SDima Dorfman.Ar value
16642277d47SDima Dorfmancan be specified as a character device special file name.
16742277d47SDima DorfmanSpecial values
168d1f8bca0SRuslan Ermilov.Cm off
16942277d47SDima Dorfmanand
170d1f8bca0SRuslan Ermilov.Cm none
17142277d47SDima Dorfmandenote
17242277d47SDima Dorfman.Dq no device .
173d0615c64SAndrew R. Reiter.Bl -column security.bsd.unprivileged_read_msgbuf integerxxx
174d8aa002eSRuslan Ermilov.It Sy "Name	Type	Changeable
175d8aa002eSRuslan Ermilov.It "kern.ostype	string	no
176d8aa002eSRuslan Ermilov.It "kern.osrelease	string	no
177d8aa002eSRuslan Ermilov.It "kern.osrevision	integer	no
178d8aa002eSRuslan Ermilov.It "kern.version	string	no
179d8aa002eSRuslan Ermilov.It "kern.maxvnodes	integer	yes
180d8aa002eSRuslan Ermilov.It "kern.maxproc	integer	no
181d8aa002eSRuslan Ermilov.It "kern.maxprocperuid	integer	yes
182d8aa002eSRuslan Ermilov.It "kern.maxfiles	integer	yes
183d8aa002eSRuslan Ermilov.It "kern.maxfilesperproc	integer	yes
184d8aa002eSRuslan Ermilov.It "kern.argmax	integer	no
185d8aa002eSRuslan Ermilov.It "kern.securelevel	integer	raise only
186d8aa002eSRuslan Ermilov.It "kern.hostname	string	yes
187d8aa002eSRuslan Ermilov.It "kern.hostid	integer	yes
188d8aa002eSRuslan Ermilov.It "kern.clockrate	struct	no
189d8aa002eSRuslan Ermilov.It "kern.posix1version	integer	no
190d8aa002eSRuslan Ermilov.It "kern.ngroups	integer	no
191d8aa002eSRuslan Ermilov.It "kern.job_control	integer	no
192d8aa002eSRuslan Ermilov.It "kern.saved_ids	integer	no
193d8aa002eSRuslan Ermilov.It "kern.boottime	struct	no
194d8aa002eSRuslan Ermilov.It "kern.domainname	string	yes
195d8aa002eSRuslan Ermilov.It "kern.filedelay	integer	yes
196d8aa002eSRuslan Ermilov.It "kern.dirdelay	integer	yes
197d8aa002eSRuslan Ermilov.It "kern.metadelay	integer	yes
198d8aa002eSRuslan Ermilov.It "kern.osreldate	string	no
199d8aa002eSRuslan Ermilov.It "kern.bootfile	string	yes
200d8aa002eSRuslan Ermilov.It "kern.corefile	string	yes
20142277d47SDima Dorfman.It "kern.dumpdev	dev_t	yes
202d8aa002eSRuslan Ermilov.It "kern.logsigexit	integer	yes
203d0615c64SAndrew R. Reiter.It "security.bsd.suser_enabled	integer	yes
204d0615c64SAndrew R. Reiter.It "security.bsd.see_other_uids	integer	yes
205d0615c64SAndrew R. Reiter.It "security.bsd.unprivileged_proc_debug	integer	yes
206d0615c64SAndrew R. Reiter.It "security.bsd.unprivileged_read_msgbuf	integer	yes
207d8aa002eSRuslan Ermilov.It "vm.loadavg	struct	no
208d8aa002eSRuslan Ermilov.It "hw.machine	string	no
209d8aa002eSRuslan Ermilov.It "hw.model	string	no
210d8aa002eSRuslan Ermilov.It "hw.ncpu	integer	no
211d8aa002eSRuslan Ermilov.It "hw.byteorder	integer	no
212d8aa002eSRuslan Ermilov.It "hw.physmem	integer	no
213d8aa002eSRuslan Ermilov.It "hw.usermem	integer	no
214d8aa002eSRuslan Ermilov.It "hw.pagesize	integer	no
215d8aa002eSRuslan Ermilov.It "hw.floatingpoint	integer	no
216d8aa002eSRuslan Ermilov.It "hw.machine_arch	string	no
217d8aa002eSRuslan Ermilov.It "machdep.console_device	dev_t	no
218d8aa002eSRuslan Ermilov.It "machdep.adjkerntz	integer	yes
219d8aa002eSRuslan Ermilov.It "machdep.disable_rtc_set	integer	yes
220617cc038SLuigi Rizzo.It "machdep.guessed_bootdev	string	no
221d8aa002eSRuslan Ermilov.It "user.cs_path	string	no
222d8aa002eSRuslan Ermilov.It "user.bc_base_max	integer	no
223d8aa002eSRuslan Ermilov.It "user.bc_dim_max	integer	no
224d8aa002eSRuslan Ermilov.It "user.bc_scale_max	integer	no
225d8aa002eSRuslan Ermilov.It "user.bc_string_max	integer	no
226d8aa002eSRuslan Ermilov.It "user.coll_weights_max	integer	no
227d8aa002eSRuslan Ermilov.It "user.expr_nest_max	integer	no
228d8aa002eSRuslan Ermilov.It "user.line_max	integer	no
229d8aa002eSRuslan Ermilov.It "user.re_dup_max	integer	no
230d8aa002eSRuslan Ermilov.It "user.posix2_version	integer	no
231d8aa002eSRuslan Ermilov.It "user.posix2_c_bind	integer	no
232d8aa002eSRuslan Ermilov.It "user.posix2_c_dev	integer	no
233d8aa002eSRuslan Ermilov.It "user.posix2_char_term	integer	no
234d8aa002eSRuslan Ermilov.It "user.posix2_fort_dev	integer	no
235d8aa002eSRuslan Ermilov.It "user.posix2_fort_run	integer	no
236d8aa002eSRuslan Ermilov.It "user.posix2_localedef	integer	no
237d8aa002eSRuslan Ermilov.It "user.posix2_sw_dev	integer	no
238d8aa002eSRuslan Ermilov.It "user.posix2_upe	integer	no
239d8aa002eSRuslan Ermilov.It "user.stream_max	integer	no
240d8aa002eSRuslan Ermilov.It "user.tzname_max	integer	no
241dea673e9SRodney W. Grimes.El
2426087df9eSRuslan Ermilov.Sh FILES
2436087df9eSRuslan Ermilov.Bl -tag -width ".In netinet/icmp_var.h" -compact
2446087df9eSRuslan Ermilov.It In sys/sysctl.h
2456087df9eSRuslan Ermilovdefinitions for top level identifiers, second level kernel and hardware
2466087df9eSRuslan Ermilovidentifiers, and user level identifiers
2476087df9eSRuslan Ermilov.It In sys/socket.h
2486087df9eSRuslan Ermilovdefinitions for second level network identifiers
2496087df9eSRuslan Ermilov.It In sys/gmon.h
2506087df9eSRuslan Ermilovdefinitions for third level profiling identifiers
2516087df9eSRuslan Ermilov.It In vm/vm_param.h
2526087df9eSRuslan Ermilovdefinitions for second level virtual memory identifiers
2536087df9eSRuslan Ermilov.It In netinet/in.h
2546087df9eSRuslan Ermilovdefinitions for third level Internet identifiers and
2556087df9eSRuslan Ermilovfourth level IP identifiers
2566087df9eSRuslan Ermilov.It In netinet/icmp_var.h
2576087df9eSRuslan Ermilovdefinitions for fourth level ICMP identifiers
2586087df9eSRuslan Ermilov.It In netinet/udp_var.h
2596087df9eSRuslan Ermilovdefinitions for fourth level UDP identifiers
2606087df9eSRuslan Ermilov.El
261dea673e9SRodney W. Grimes.Sh EXAMPLES
262dea673e9SRodney W. GrimesFor example, to retrieve the maximum number of processes allowed
263b91e5f67SSteve Pricein the system, one would use the following request:
264def778b8SRuslan Ermilov.Pp
265def778b8SRuslan Ermilov.Dl "sysctl kern.maxproc"
266dea673e9SRodney W. Grimes.Pp
267dea673e9SRodney W. GrimesTo set the maximum number of processes allowed
268b91e5f67SSteve Priceper uid to 1000, one would use the following request:
269def778b8SRuslan Ermilov.Pp
2707e7cdfa0SYaroslav Tykhiy.Dl "sysctl kern.maxprocperuid=1000"
271dea673e9SRodney W. Grimes.Pp
27242277d47SDima DorfmanThe device used for crash dumps can be specified using:
27342277d47SDima Dorfman.Pp
27442277d47SDima Dorfman.Dl "sysctl kern.dumpdev=/dev/somedev"
27542277d47SDima Dorfman.Pp
27642277d47SDima Dorfmanwhich is equivalent to
27742277d47SDima Dorfman.Pp
27842277d47SDima Dorfman.Dl "dumpon /dev/somedev"
27942277d47SDima Dorfman.Pp
280dea673e9SRodney W. GrimesInformation about the system clock rate may be obtained with:
281def778b8SRuslan Ermilov.Pp
282def778b8SRuslan Ermilov.Dl "sysctl kern.clockrate"
283dea673e9SRodney W. Grimes.Pp
284d9b1bc77SPhilippe CharnierInformation about the load average history may be obtained with:
285def778b8SRuslan Ermilov.Pp
286def778b8SRuslan Ermilov.Dl "sysctl vm.loadavg"
2871d86b91cSPoul-Henning Kamp.Pp
2881d86b91cSPoul-Henning KampMore variables than these exist, and the best and likely only place
2891d86b91cSPoul-Henning Kampto search for their deeper meaning is undoubtedly the source where
2901d86b91cSPoul-Henning Kampthey are defined.
2912a6bc064SYaroslav Tykhiy.Sh COMPATIBILITY
2922a6bc064SYaroslav TykhiyThe
2932a6bc064SYaroslav Tykhiy.Fl w
2942a6bc064SYaroslav Tykhiyoption has been deprecated and is silently ignored.
295dea673e9SRodney W. Grimes.Sh SEE ALSO
29697a00e76SAlexey Zelkin.Xr sysctl 3 ,
29743308797SChristian Brueffer.Xr loader.conf 5 ,
29843308797SChristian Brueffer.Xr sysctl.conf 5 ,
29943308797SChristian Brueffer.Xr loader 8
300dea673e9SRodney W. Grimes.Sh HISTORY
301629e80efSPhilippe CharnierA
302629e80efSPhilippe Charnier.Nm
303629e80efSPhilippe Charnierutility first appeared in
30485cf659aSMike Pritchard.Bx 4.4 .
3051d86b91cSPoul-Henning Kamp.Pp
30685cf659aSMike PritchardIn
307d9b1bc77SPhilippe Charnier.Fx 2.2 ,
308d9b1bc77SPhilippe Charnier.Nm
30985cf659aSMike Pritchardwas significantly remodeled.
3106087df9eSRuslan Ermilov.Sh BUGS
3116087df9eSRuslan ErmilovThe
3126087df9eSRuslan Ermilov.Nm
3136087df9eSRuslan Ermilovutility presently exploits an undocumented interface to the kernel
3146087df9eSRuslan Ermilovsysctl facility to traverse the sysctl tree and to retrieve format
3156087df9eSRuslan Ermilovand name information.
3166087df9eSRuslan ErmilovThis correct interface is being thought about for the time being.
317