xref: /freebsd/sbin/sysctl/sysctl.8 (revision 433087977a16c6967817452d15d15bff71d8de0c)
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.\"
3542277d47SDima Dorfman.Dd March 10, 2002
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
43d0b8aabbSAnton Berezin.Op Fl beNnox
449a2402bcSDag-Erling Smørgrav.Ar name Ns Op = Ns Ar value
459a2402bcSDag-Erling Smørgrav.Ar ...
467c7fb079SRuslan Ermilov.Nm
476105f815SLuigi Rizzo.Op Fl bdeNnox
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.
54def778b8SRuslan ErmilovThe state to be retrieved or set is described using a
55def778b8SRuslan Ermilov.Dq Management Information Base
56def778b8SRuslan Ermilov.Pq Dq MIB
57def778b8SRuslan Ermilovstyle name, described as a dotted set of
589a2402bcSDag-Erling Smørgravcomponents.
591d86b91cSPoul-Henning Kamp.Pp
60d9b1bc77SPhilippe CharnierThe following options are available:
61d9b1bc77SPhilippe Charnier.Bl -tag -width indent
62d9b1bc77SPhilippe Charnier.It Fl A
639a2402bcSDag-Erling SmørgravEquivalent to
64def778b8SRuslan Ermilov.Fl o a
659a2402bcSDag-Erling Smørgrav(for compatibility).
669a2402bcSDag-Erling Smørgrav.It Fl a
679a2402bcSDag-Erling SmørgravList all the currently available non-opaque values.
689a2402bcSDag-Erling SmørgravThis option is ignored if one or more variable names are specified on
699a2402bcSDag-Erling Smørgravthe command line.
70c4da2cc9SDima Dorfman.It Fl b
71c4da2cc9SDima DorfmanForce the value of the variable(s) to be output in raw, binary format.
72c4da2cc9SDima DorfmanNo names are printed and no terminating newlines are output.
73c4da2cc9SDima DorfmanThis is mostly useful with a single variable.
746105f815SLuigi Rizzo.It Fl d
756105f815SLuigi RizzoPrint the description of the variable instead of its value.
76d0b8aabbSAnton Berezin.It Fl e
7728dc1d23SAnton BerezinSeparate the name and the value of the variable(s) with
7828dc1d23SAnton Berezin.Ql = .
79d0b8aabbSAnton BerezinThis is useful for producing output which can be fed back to the
80d0b8aabbSAnton Berezin.Nm
81d0b8aabbSAnton Berezinutility.
82d0b8aabbSAnton BerezinThis option is ignored if either
83d0b8aabbSAnton Berezin.Fl N
84d0b8aabbSAnton Berezinor
85d0b8aabbSAnton Berezin.Fl n
86d0b8aabbSAnton Berezinis specified, or a variable is being set.
870ef56fd8SDag-Erling Smørgrav.It Fl N
880ef56fd8SDag-Erling SmørgravShow only variable names, not their values.
899a2402bcSDag-Erling SmørgravThis is particularly useful with shells that offer programmable
909a2402bcSDag-Erling Smørgravcompletion.
919a2402bcSDag-Erling SmørgravTo enable completion of variable names in
929a2402bcSDag-Erling Smørgrav.Nm zsh ,
939a2402bcSDag-Erling Smørgravuse the following code:
94def778b8SRuslan Ermilov.Bd -literal -offset indent
959a2402bcSDag-Erling Smørgravlistsysctls () { set -A reply $(sysctl -AN ${1%.*}) }
969a2402bcSDag-Erling Smørgravcompctl -K listsysctls sysctl
979a2402bcSDag-Erling Smørgrav.Ed
98d9b1bc77SPhilippe Charnier.It Fl n
999a2402bcSDag-Erling SmørgravShow only variable values, not their names.
1009a2402bcSDag-Erling SmørgravThis option is useful for setting shell variables.
101def778b8SRuslan ErmilovFor instance, to save the pagesize in variable
102def778b8SRuslan Ermilov.Va psize ,
103def778b8SRuslan Ermilovuse:
104def778b8SRuslan Ermilov.Pp
105def778b8SRuslan Ermilov.Dl "set psize=`sysctl -n hw.pagesize`"
106c4da2cc9SDima Dorfman.It Fl o
1079a2402bcSDag-Erling SmørgravShow opaque variables (which are normally suppressed).
1089a2402bcSDag-Erling SmørgravThe format and length are printed, as well as a hex dump of the first
1099a2402bcSDag-Erling Smørgravsixteen bytes of the value.
1109a2402bcSDag-Erling Smørgrav.It Fl X
1119a2402bcSDag-Erling SmørgravEquivalent to
112def778b8SRuslan Ermilov.Fl x a
1139a2402bcSDag-Erling Smørgrav(for compatibility).
1149a2402bcSDag-Erling Smørgrav.It Fl x
1159a2402bcSDag-Erling SmørgravAs
1169a2402bcSDag-Erling Smørgrav.Fl o ,
1179a2402bcSDag-Erling Smørgravbut prints a hex dump of the entire value instead of just the first
1189a2402bcSDag-Erling Smørgravfew bytes.
119d9b1bc77SPhilippe Charnier.El
120dea673e9SRodney W. Grimes.Pp
121dea673e9SRodney W. GrimesThe information available from
122d9b1bc77SPhilippe Charnier.Nm
12342277d47SDima Dorfmanconsists of integers, strings, devices
12442277d47SDima Dorfman.Pq Vt dev_t ,
12542277d47SDima Dorfmanand opaque types.
126629e80efSPhilippe CharnierThe
127629e80efSPhilippe Charnier.Nm
128629e80efSPhilippe Charnierutility
1291d86b91cSPoul-Henning Kamponly knows about a couple of opaque types, and will resort to hexdumps
1301d86b91cSPoul-Henning Kampfor the rest.
1311d86b91cSPoul-Henning KampThe opaque information is much more useful if retrieved by special
132dea673e9SRodney W. Grimespurpose programs such as
133def778b8SRuslan Ermilov.Nm ps , systat ,
134dea673e9SRodney W. Grimesand
135dea673e9SRodney W. Grimes.Nm netstat .
1361d86b91cSPoul-Henning Kamp.Pp
13743308797SChristian BruefferSome of the variables which can not be modified during normal system
13843308797SChristian Bruefferoperation can be initialized by setting them from
13943308797SChristian Brueffer.Xr loader 8 .
14043308797SChristian BruefferThis can for example be done by setting the variable in
14143308797SChristian Brueffer.Xr loader.conf 5 .
14243308797SChristian Brueffer.Pp
1434a8d0283SMike PritchardThe string and integer information is summarized below.
144dea673e9SRodney W. GrimesFor a detailed description of these variable see
145dea673e9SRodney W. Grimes.Xr sysctl 3 .
1461d86b91cSPoul-Henning Kamp.Pp
147dea673e9SRodney W. GrimesThe changeable column indicates whether a process with appropriate
148dea673e9SRodney W. Grimesprivilege can change the value.
14942277d47SDima DorfmanString, integer, and devices values can be set using
15042277d47SDima Dorfman.Nm .
15142277d47SDima DorfmanFor device values,
15242277d47SDima Dorfman.Ar value
15342277d47SDima Dorfmancan be specified as a character device special file name.
15442277d47SDima DorfmanSpecial values
155d1f8bca0SRuslan Ermilov.Cm off
15642277d47SDima Dorfmanand
157d1f8bca0SRuslan Ermilov.Cm none
15842277d47SDima Dorfmandenote
15942277d47SDima Dorfman.Dq no device .
160d0615c64SAndrew R. Reiter.Bl -column security.bsd.unprivileged_read_msgbuf integerxxx
161d8aa002eSRuslan Ermilov.It Sy "Name	Type	Changeable
162d8aa002eSRuslan Ermilov.It "kern.ostype	string	no
163d8aa002eSRuslan Ermilov.It "kern.osrelease	string	no
164d8aa002eSRuslan Ermilov.It "kern.osrevision	integer	no
165d8aa002eSRuslan Ermilov.It "kern.version	string	no
166d8aa002eSRuslan Ermilov.It "kern.maxvnodes	integer	yes
167d8aa002eSRuslan Ermilov.It "kern.maxproc	integer	no
168d8aa002eSRuslan Ermilov.It "kern.maxprocperuid	integer	yes
169d8aa002eSRuslan Ermilov.It "kern.maxfiles	integer	yes
170d8aa002eSRuslan Ermilov.It "kern.maxfilesperproc	integer	yes
171d8aa002eSRuslan Ermilov.It "kern.argmax	integer	no
172d8aa002eSRuslan Ermilov.It "kern.securelevel	integer	raise only
173d8aa002eSRuslan Ermilov.It "kern.hostname	string	yes
174d8aa002eSRuslan Ermilov.It "kern.hostid	integer	yes
175d8aa002eSRuslan Ermilov.It "kern.clockrate	struct	no
176d8aa002eSRuslan Ermilov.It "kern.posix1version	integer	no
177d8aa002eSRuslan Ermilov.It "kern.ngroups	integer	no
178d8aa002eSRuslan Ermilov.It "kern.job_control	integer	no
179d8aa002eSRuslan Ermilov.It "kern.saved_ids	integer	no
180d8aa002eSRuslan Ermilov.It "kern.boottime	struct	no
181d8aa002eSRuslan Ermilov.It "kern.domainname	string	yes
182d8aa002eSRuslan Ermilov.It "kern.filedelay	integer	yes
183d8aa002eSRuslan Ermilov.It "kern.dirdelay	integer	yes
184d8aa002eSRuslan Ermilov.It "kern.metadelay	integer	yes
185d8aa002eSRuslan Ermilov.It "kern.osreldate	string	no
186d8aa002eSRuslan Ermilov.It "kern.bootfile	string	yes
187d8aa002eSRuslan Ermilov.It "kern.corefile	string	yes
18842277d47SDima Dorfman.It "kern.dumpdev	dev_t	yes
189d8aa002eSRuslan Ermilov.It "kern.logsigexit	integer	yes
190d0615c64SAndrew R. Reiter.It "security.bsd.suser_enabled	integer	yes
191d0615c64SAndrew R. Reiter.It "security.bsd.see_other_uids	integer	yes
192d0615c64SAndrew R. Reiter.It "security.bsd.unprivileged_proc_debug	integer	yes
193d0615c64SAndrew R. Reiter.It "security.bsd.unprivileged_read_msgbuf	integer	yes
194d8aa002eSRuslan Ermilov.It "vm.loadavg	struct	no
195d8aa002eSRuslan Ermilov.It "hw.machine	string	no
196d8aa002eSRuslan Ermilov.It "hw.model	string	no
197d8aa002eSRuslan Ermilov.It "hw.ncpu	integer	no
198d8aa002eSRuslan Ermilov.It "hw.byteorder	integer	no
199d8aa002eSRuslan Ermilov.It "hw.physmem	integer	no
200d8aa002eSRuslan Ermilov.It "hw.usermem	integer	no
201d8aa002eSRuslan Ermilov.It "hw.pagesize	integer	no
202d8aa002eSRuslan Ermilov.It "hw.floatingpoint	integer	no
203d8aa002eSRuslan Ermilov.It "hw.machine_arch	string	no
204d8aa002eSRuslan Ermilov.It "machdep.console_device	dev_t	no
205d8aa002eSRuslan Ermilov.It "machdep.adjkerntz	integer	yes
206d8aa002eSRuslan Ermilov.It "machdep.disable_rtc_set	integer	yes
207617cc038SLuigi Rizzo.It "machdep.guessed_bootdev	string	no
208d8aa002eSRuslan Ermilov.It "user.cs_path	string	no
209d8aa002eSRuslan Ermilov.It "user.bc_base_max	integer	no
210d8aa002eSRuslan Ermilov.It "user.bc_dim_max	integer	no
211d8aa002eSRuslan Ermilov.It "user.bc_scale_max	integer	no
212d8aa002eSRuslan Ermilov.It "user.bc_string_max	integer	no
213d8aa002eSRuslan Ermilov.It "user.coll_weights_max	integer	no
214d8aa002eSRuslan Ermilov.It "user.expr_nest_max	integer	no
215d8aa002eSRuslan Ermilov.It "user.line_max	integer	no
216d8aa002eSRuslan Ermilov.It "user.re_dup_max	integer	no
217d8aa002eSRuslan Ermilov.It "user.posix2_version	integer	no
218d8aa002eSRuslan Ermilov.It "user.posix2_c_bind	integer	no
219d8aa002eSRuslan Ermilov.It "user.posix2_c_dev	integer	no
220d8aa002eSRuslan Ermilov.It "user.posix2_char_term	integer	no
221d8aa002eSRuslan Ermilov.It "user.posix2_fort_dev	integer	no
222d8aa002eSRuslan Ermilov.It "user.posix2_fort_run	integer	no
223d8aa002eSRuslan Ermilov.It "user.posix2_localedef	integer	no
224d8aa002eSRuslan Ermilov.It "user.posix2_sw_dev	integer	no
225d8aa002eSRuslan Ermilov.It "user.posix2_upe	integer	no
226d8aa002eSRuslan Ermilov.It "user.stream_max	integer	no
227d8aa002eSRuslan Ermilov.It "user.tzname_max	integer	no
228dea673e9SRodney W. Grimes.El
229dea673e9SRodney W. Grimes.Sh EXAMPLES
230dea673e9SRodney W. GrimesFor example, to retrieve the maximum number of processes allowed
231b91e5f67SSteve Pricein the system, one would use the following request:
232def778b8SRuslan Ermilov.Pp
233def778b8SRuslan Ermilov.Dl "sysctl kern.maxproc"
234dea673e9SRodney W. Grimes.Pp
235dea673e9SRodney W. GrimesTo set the maximum number of processes allowed
236b91e5f67SSteve Priceper uid to 1000, one would use the following request:
237def778b8SRuslan Ermilov.Pp
2387e7cdfa0SYaroslav Tykhiy.Dl "sysctl kern.maxprocperuid=1000"
239dea673e9SRodney W. Grimes.Pp
24042277d47SDima DorfmanThe device used for crash dumps can be specified using:
24142277d47SDima Dorfman.Pp
24242277d47SDima Dorfman.Dl "sysctl kern.dumpdev=/dev/somedev"
24342277d47SDima Dorfman.Pp
24442277d47SDima Dorfmanwhich is equivalent to
24542277d47SDima Dorfman.Pp
24642277d47SDima Dorfman.Dl "dumpon /dev/somedev"
24742277d47SDima Dorfman.Pp
248dea673e9SRodney W. GrimesInformation about the system clock rate may be obtained with:
249def778b8SRuslan Ermilov.Pp
250def778b8SRuslan Ermilov.Dl "sysctl kern.clockrate"
251dea673e9SRodney W. Grimes.Pp
252d9b1bc77SPhilippe CharnierInformation about the load average history may be obtained with:
253def778b8SRuslan Ermilov.Pp
254def778b8SRuslan Ermilov.Dl "sysctl vm.loadavg"
2551d86b91cSPoul-Henning Kamp.Pp
2561d86b91cSPoul-Henning KampMore variables than these exist, and the best and likely only place
2571d86b91cSPoul-Henning Kampto search for their deeper meaning is undoubtedly the source where
2581d86b91cSPoul-Henning Kampthey are defined.
259dea673e9SRodney W. Grimes.Sh FILES
260e8b02a42SRuslan Ermilov.Bl -tag -width ".Aq Pa netinet/icmp_var.h" -compact
261def778b8SRuslan Ermilov.It Aq Pa sys/sysctl.h
262dea673e9SRodney W. Grimesdefinitions for top level identifiers, second level kernel and hardware
263dea673e9SRodney W. Grimesidentifiers, and user level identifiers
264def778b8SRuslan Ermilov.It Aq Pa sys/socket.h
265dea673e9SRodney W. Grimesdefinitions for second level network identifiers
266def778b8SRuslan Ermilov.It Aq Pa sys/gmon.h
267dea673e9SRodney W. Grimesdefinitions for third level profiling identifiers
268def778b8SRuslan Ermilov.It Aq Pa vm/vm_param.h
269dea673e9SRodney W. Grimesdefinitions for second level virtual memory identifiers
270def778b8SRuslan Ermilov.It Aq Pa netinet/in.h
271dea673e9SRodney W. Grimesdefinitions for third level Internet identifiers and
272dea673e9SRodney W. Grimesfourth level IP identifiers
273def778b8SRuslan Ermilov.It Aq Pa netinet/icmp_var.h
274dea673e9SRodney W. Grimesdefinitions for fourth level ICMP identifiers
275def778b8SRuslan Ermilov.It Aq Pa netinet/udp_var.h
276dea673e9SRodney W. Grimesdefinitions for fourth level UDP identifiers
277dea673e9SRodney W. Grimes.El
2782a6bc064SYaroslav Tykhiy.Sh COMPATIBILITY
2792a6bc064SYaroslav TykhiyThe
2802a6bc064SYaroslav Tykhiy.Fl w
2812a6bc064SYaroslav Tykhiyoption has been deprecated and is silently ignored.
282dea673e9SRodney W. Grimes.Sh SEE ALSO
28397a00e76SAlexey Zelkin.Xr sysctl 3 ,
28443308797SChristian Brueffer.Xr loader.conf 5 ,
28543308797SChristian Brueffer.Xr sysctl.conf 5 ,
28643308797SChristian Brueffer.Xr loader 8
2871d86b91cSPoul-Henning Kamp.Sh BUGS
288629e80efSPhilippe CharnierThe
289629e80efSPhilippe Charnier.Nm
290629e80efSPhilippe Charnierutility presently exploits an undocumented interface to the kernel
2914a8d0283SMike Pritchardsysctl facility to traverse the sysctl tree and to retrieve format
2921d86b91cSPoul-Henning Kampand name information.
2931d86b91cSPoul-Henning KampThis correct interface is being thought about for the time being.
294dea673e9SRodney W. Grimes.Sh HISTORY
295629e80efSPhilippe CharnierA
296629e80efSPhilippe Charnier.Nm
297629e80efSPhilippe Charnierutility first appeared in
29885cf659aSMike Pritchard.Bx 4.4 .
2991d86b91cSPoul-Henning Kamp.Pp
30085cf659aSMike PritchardIn
301d9b1bc77SPhilippe Charnier.Fx 2.2 ,
302d9b1bc77SPhilippe Charnier.Nm
30385cf659aSMike Pritchardwas significantly remodeled.
304