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. 12fbbd9655SWarner Losh.\" 3. 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.\" 31*0438e9beSMateusz Piotrowski.Dd June 30, 2022 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 39c68d0f8bSGuangyuan Yang.Op Fl bdehiNnoTtqWx 4075820005SJohn-Mark Gurney.Op Fl B Ar bufsize 41da178c77SXin LI.Op Fl f Ar filename 422365fe56SJohn Baldwin.Ar name Ns Op = Ns Ar value Ns Op , Ns Ar value 439a2402bcSDag-Erling Smørgrav.Ar ... 447c7fb079SRuslan Ermilov.Nm 45c68d0f8bSGuangyuan Yang.Op Fl bdehNnoTtqWx 4675820005SJohn-Mark Gurney.Op Fl B Ar bufsize 479a2402bcSDag-Erling Smørgrav.Fl a 48dea673e9SRodney W. Grimes.Sh DESCRIPTION 49dea673e9SRodney W. GrimesThe 50d9b1bc77SPhilippe Charnier.Nm 519a2402bcSDag-Erling Smørgravutility retrieves kernel state and allows processes with appropriate 529a2402bcSDag-Erling Smørgravprivilege to set kernel state. 53def778b8SRuslan ErmilovThe state to be retrieved or set is described using a 54def778b8SRuslan Ermilov.Dq Management Information Base 55def778b8SRuslan Ermilov.Pq Dq MIB 56def778b8SRuslan Ermilovstyle name, described as a dotted set of 579a2402bcSDag-Erling Smørgravcomponents. 581d86b91cSPoul-Henning Kamp.Pp 59d9b1bc77SPhilippe CharnierThe following options are available: 60d9b1bc77SPhilippe Charnier.Bl -tag -width indent 61d9b1bc77SPhilippe Charnier.It Fl A 629a2402bcSDag-Erling SmørgravEquivalent to 63def778b8SRuslan Ermilov.Fl o a 649a2402bcSDag-Erling Smørgrav(for compatibility). 659a2402bcSDag-Erling Smørgrav.It Fl a 661dee7c74SColin PercivalList all the currently available values except for those which are 671dee7c74SColin Percivalopaque or excluded from listing via the 681dee7c74SColin Percival.Dv CTLFLAG_SKIP 691dee7c74SColin Percivalflag. 709a2402bcSDag-Erling SmørgravThis option is ignored if one or more variable names are specified on 719a2402bcSDag-Erling Smørgravthe command line. 72c4da2cc9SDima Dorfman.It Fl b 73c4da2cc9SDima DorfmanForce the value of the variable(s) to be output in raw, binary format. 74c4da2cc9SDima DorfmanNo names are printed and no terminating newlines are output. 75c4da2cc9SDima DorfmanThis is mostly useful with a single variable. 7675820005SJohn-Mark Gurney.It Fl B Ar bufsize 7775820005SJohn-Mark GurneySet the buffer size to read from the 7875820005SJohn-Mark Gurney.Nm 7975820005SJohn-Mark Gurneyto 8075820005SJohn-Mark Gurney.Ar bufsize . 8175820005SJohn-Mark GurneyThis is necessary for a 8275820005SJohn-Mark Gurney.Nm 8375820005SJohn-Mark Gurneythat has variable length, and the probe value of 0 is a valid length, such as 8475820005SJohn-Mark Gurney.Va kern.arandom . 856105f815SLuigi Rizzo.It Fl d 866105f815SLuigi RizzoPrint the description of the variable instead of its value. 87d0b8aabbSAnton Berezin.It Fl e 8828dc1d23SAnton BerezinSeparate the name and the value of the variable(s) with 8928dc1d23SAnton Berezin.Ql = . 90d0b8aabbSAnton BerezinThis is useful for producing output which can be fed back to the 91d0b8aabbSAnton Berezin.Nm 92d0b8aabbSAnton Berezinutility. 93d0b8aabbSAnton BerezinThis option is ignored if either 94d0b8aabbSAnton Berezin.Fl N 95d0b8aabbSAnton Berezinor 96d0b8aabbSAnton Berezin.Fl n 97d0b8aabbSAnton Berezinis specified, or a variable is being set. 98da178c77SXin LI.It Fl f Ar filename 99da178c77SXin LISpecify a file which contains a pair of name and value in each line. 100da178c77SXin LI.Nm 101da178c77SXin LIreads and processes the specified file first and then processes the name 102da178c77SXin LIand value pairs in the command line argument. 10345817aaaSDag-Erling Smørgrav.It Fl h 10445817aaaSDag-Erling SmørgravFormat output for human, rather than machine, readability. 10524b2aa32SGavin Atkinson.It Fl i 10624b2aa32SGavin AtkinsonIgnore unknown OIDs. 10724b2aa32SGavin AtkinsonThe purpose is to make use of 10824b2aa32SGavin Atkinson.Nm 10924b2aa32SGavin Atkinsonfor collecting data from a variety of machines (not all of which 11024b2aa32SGavin Atkinsonare necessarily running exactly the same software) easier. 1110ef56fd8SDag-Erling Smørgrav.It Fl N 1120ef56fd8SDag-Erling SmørgravShow only variable names, not their values. 1139a2402bcSDag-Erling SmørgravThis is particularly useful with shells that offer programmable 1149a2402bcSDag-Erling Smørgravcompletion. 1159a2402bcSDag-Erling SmørgravTo enable completion of variable names in 116f0ea72a0SChristian Brueffer.Xr zsh 1 Pq Pa ports/shells/zsh , 1179a2402bcSDag-Erling Smørgravuse the following code: 118def778b8SRuslan Ermilov.Bd -literal -offset indent 1199a2402bcSDag-Erling Smørgravlistsysctls () { set -A reply $(sysctl -AN ${1%.*}) } 1209a2402bcSDag-Erling Smørgravcompctl -K listsysctls sysctl 1219a2402bcSDag-Erling Smørgrav.Ed 122ec3724d9SHiten Pandya.Pp 123ec3724d9SHiten PandyaTo enable completion of variable names in 124ec3724d9SHiten Pandya.Xr tcsh 1 , 125ec3724d9SHiten Pandyause: 12621414470SRuslan Ermilov.Pp 12721414470SRuslan Ermilov.Dl "complete sysctl 'n/*/`sysctl -Na`/'" 128d9b1bc77SPhilippe Charnier.It Fl n 1290ad4bfaeSFernando ApesteguíaDo not show variable names. 1309a2402bcSDag-Erling SmørgravThis option is useful for setting shell variables. 131def778b8SRuslan ErmilovFor instance, to save the pagesize in variable 132def778b8SRuslan Ermilov.Va psize , 133def778b8SRuslan Ermilovuse: 134def778b8SRuslan Ermilov.Pp 135def778b8SRuslan Ermilov.Dl "set psize=`sysctl -n hw.pagesize`" 136c4da2cc9SDima Dorfman.It Fl o 1379a2402bcSDag-Erling SmørgravShow opaque variables (which are normally suppressed). 1389a2402bcSDag-Erling SmørgravThe format and length are printed, as well as a hex dump of the first 1399a2402bcSDag-Erling Smørgravsixteen bytes of the value. 140f93d36fdSRobert Watson.It Fl q 141f93d36fdSRobert WatsonSuppress some warnings generated by 142f93d36fdSRobert Watson.Nm 143f93d36fdSRobert Watsonto standard error. 1449ecd2e32SAlfred Perlstein.It Fl T 14575820005SJohn-Mark GurneyDisplay only variables that are settable via loader (CTLFLAG_TUN). 1468020192dSMarcelo Araujo.It Fl t 1478020192dSMarcelo AraujoPrint the type of the variable. 1489ecd2e32SAlfred Perlstein.It Fl W 149b85e9d27SDevin TeskeDisplay only writable variables that are not statistical. 1509ecd2e32SAlfred PerlsteinUseful for determining the set of runtime tunable sysctls. 1519a2402bcSDag-Erling Smørgrav.It Fl X 1529a2402bcSDag-Erling SmørgravEquivalent to 153def778b8SRuslan Ermilov.Fl x a 1549a2402bcSDag-Erling Smørgrav(for compatibility). 1559a2402bcSDag-Erling Smørgrav.It Fl x 1569a2402bcSDag-Erling SmørgravAs 1579a2402bcSDag-Erling Smørgrav.Fl o , 1589a2402bcSDag-Erling Smørgravbut prints a hex dump of the entire value instead of just the first 1599a2402bcSDag-Erling Smørgravfew bytes. 160d9b1bc77SPhilippe Charnier.El 161dea673e9SRodney W. Grimes.Pp 162dea673e9SRodney W. GrimesThe information available from 163d9b1bc77SPhilippe Charnier.Nm 1645bf6a940SMatthew D Flemingconsists of integers, strings, and opaque types. 165629e80efSPhilippe CharnierThe 166629e80efSPhilippe Charnier.Nm 167629e80efSPhilippe Charnierutility 1681d86b91cSPoul-Henning Kamponly knows about a couple of opaque types, and will resort to hexdumps 1691d86b91cSPoul-Henning Kampfor the rest. 1701d86b91cSPoul-Henning KampThe opaque information is much more useful if retrieved by special 171dea673e9SRodney W. Grimespurpose programs such as 1724f898f94SPhilippe Charnier.Xr ps 1 , 1734f898f94SPhilippe Charnier.Xr systat 1 , 174dea673e9SRodney W. Grimesand 1754f898f94SPhilippe Charnier.Xr netstat 1 . 1761d86b91cSPoul-Henning Kamp.Pp 17743308797SChristian BruefferSome of the variables which cannot be modified during normal system 178ab5e6ef0SChristian Bruefferoperation can be initialized via 179ab5e6ef0SChristian Brueffer.Xr loader 8 180ab5e6ef0SChristian Brueffertunables. 181ab5e6ef0SChristian BruefferThis can for example be done by setting them in 18243308797SChristian Brueffer.Xr loader.conf 5 . 183ab5e6ef0SChristian BruefferPlease refer to 184ab5e6ef0SChristian Brueffer.Xr loader.conf 5 185ab5e6ef0SChristian Bruefferfor more information on which tunables are available and how to set them. 18643308797SChristian Brueffer.Pp 1874a8d0283SMike PritchardThe string and integer information is summarized below. 188dea673e9SRodney W. GrimesFor a detailed description of these variable see 189dea673e9SRodney W. Grimes.Xr sysctl 3 . 1901d86b91cSPoul-Henning Kamp.Pp 191dea673e9SRodney W. GrimesThe changeable column indicates whether a process with appropriate 192dea673e9SRodney W. Grimesprivilege can change the value. 1937e265faeSMatthew D FlemingString and integer values can be set using 19442277d47SDima Dorfman.Nm . 195d0615c64SAndrew R. Reiter.Bl -column security.bsd.unprivileged_read_msgbuf integerxxx 196c2965cd1SJoel Dahl.It Sy "Name Type Changeable" 197c2965cd1SJoel Dahl.It "kern.ostype string no" 198c2965cd1SJoel Dahl.It "kern.osrelease string no" 199c2965cd1SJoel Dahl.It "kern.osrevision integer no" 200c2965cd1SJoel Dahl.It "kern.version string no" 201c2965cd1SJoel Dahl.It "kern.maxvnodes integer yes" 202c2965cd1SJoel Dahl.It "kern.maxproc integer no" 203c2965cd1SJoel Dahl.It "kern.maxprocperuid integer yes" 204c2965cd1SJoel Dahl.It "kern.maxfiles integer yes" 205c2965cd1SJoel Dahl.It "kern.maxfilesperproc integer yes" 206c2965cd1SJoel Dahl.It "kern.argmax integer no" 207c2965cd1SJoel Dahl.It "kern.securelevel integer raise only" 208c2965cd1SJoel Dahl.It "kern.hostname string yes" 209c2965cd1SJoel Dahl.It "kern.hostid integer yes" 210c2965cd1SJoel Dahl.It "kern.clockrate struct no" 211c2965cd1SJoel Dahl.It "kern.posix1version integer no" 212c2965cd1SJoel Dahl.It "kern.ngroups integer no" 213c2965cd1SJoel Dahl.It "kern.job_control integer no" 214c2965cd1SJoel Dahl.It "kern.saved_ids integer no" 215c2965cd1SJoel Dahl.It "kern.boottime struct no" 216c2965cd1SJoel Dahl.It "kern.domainname string yes" 217c2965cd1SJoel Dahl.It "kern.filedelay integer yes" 218c2965cd1SJoel Dahl.It "kern.dirdelay integer yes" 219c2965cd1SJoel Dahl.It "kern.metadelay integer yes" 220ed007b78SAllan Jude.It "kern.osreldate integer no" 221c2965cd1SJoel Dahl.It "kern.bootfile string yes" 222c2965cd1SJoel Dahl.It "kern.corefile string yes" 223c2965cd1SJoel Dahl.It "kern.logsigexit integer yes" 224c2965cd1SJoel Dahl.It "security.bsd.suser_enabled integer yes" 225c2965cd1SJoel Dahl.It "security.bsd.see_other_uids integer yes" 226c2965cd1SJoel Dahl.It "security.bsd.unprivileged_proc_debug integer yes" 227c2965cd1SJoel Dahl.It "security.bsd.unprivileged_read_msgbuf integer yes" 228c2965cd1SJoel Dahl.It "vm.loadavg struct no" 229c2965cd1SJoel Dahl.It "hw.machine string no" 230c2965cd1SJoel Dahl.It "hw.model string no" 231c2965cd1SJoel Dahl.It "hw.ncpu integer no" 232c2965cd1SJoel Dahl.It "hw.byteorder integer no" 233c2965cd1SJoel Dahl.It "hw.physmem integer no" 234c2965cd1SJoel Dahl.It "hw.usermem integer no" 235c2965cd1SJoel Dahl.It "hw.pagesize integer no" 236c2965cd1SJoel Dahl.It "hw.floatingpoint integer no" 237c2965cd1SJoel Dahl.It "hw.machine_arch string no" 238c2965cd1SJoel Dahl.It "hw.realmem integer no" 239c2965cd1SJoel Dahl.It "machdep.adjkerntz integer yes" 240c2965cd1SJoel Dahl.It "machdep.disable_rtc_set integer yes" 241c2965cd1SJoel Dahl.It "machdep.guessed_bootdev string no" 242c2965cd1SJoel Dahl.It "user.cs_path string no" 243c2965cd1SJoel Dahl.It "user.bc_base_max integer no" 244c2965cd1SJoel Dahl.It "user.bc_dim_max integer no" 245c2965cd1SJoel Dahl.It "user.bc_scale_max integer no" 246c2965cd1SJoel Dahl.It "user.bc_string_max integer no" 247c2965cd1SJoel Dahl.It "user.coll_weights_max integer no" 248c2965cd1SJoel Dahl.It "user.expr_nest_max integer no" 249c2965cd1SJoel Dahl.It "user.line_max integer no" 250c2965cd1SJoel Dahl.It "user.re_dup_max integer no" 251c2965cd1SJoel Dahl.It "user.posix2_version integer no" 252c2965cd1SJoel Dahl.It "user.posix2_c_bind integer no" 253c2965cd1SJoel Dahl.It "user.posix2_c_dev integer no" 254c2965cd1SJoel Dahl.It "user.posix2_char_term integer no" 255c2965cd1SJoel Dahl.It "user.posix2_fort_dev integer no" 256c2965cd1SJoel Dahl.It "user.posix2_fort_run integer no" 257c2965cd1SJoel Dahl.It "user.posix2_localedef integer no" 258c2965cd1SJoel Dahl.It "user.posix2_sw_dev integer no" 259c2965cd1SJoel Dahl.It "user.posix2_upe integer no" 260c2965cd1SJoel Dahl.It "user.stream_max integer no" 261c2965cd1SJoel Dahl.It "user.tzname_max integer no" 26277b793c4SStefan Eßer.It "user.localbase string no" 263dea673e9SRodney W. Grimes.El 2646087df9eSRuslan Ermilov.Sh FILES 2656087df9eSRuslan Ermilov.Bl -tag -width ".In netinet/icmp_var.h" -compact 2666087df9eSRuslan Ermilov.It In sys/sysctl.h 2676087df9eSRuslan Ermilovdefinitions for top level identifiers, second level kernel and hardware 2686087df9eSRuslan Ermilovidentifiers, and user level identifiers 2696087df9eSRuslan Ermilov.It In sys/socket.h 2706087df9eSRuslan Ermilovdefinitions for second level network identifiers 2716087df9eSRuslan Ermilov.It In sys/gmon.h 2726087df9eSRuslan Ermilovdefinitions for third level profiling identifiers 2736087df9eSRuslan Ermilov.It In vm/vm_param.h 2746087df9eSRuslan Ermilovdefinitions for second level virtual memory identifiers 2756087df9eSRuslan Ermilov.It In netinet/in.h 2766087df9eSRuslan Ermilovdefinitions for third level Internet identifiers and 2776087df9eSRuslan Ermilovfourth level IP identifiers 2786087df9eSRuslan Ermilov.It In netinet/icmp_var.h 2796087df9eSRuslan Ermilovdefinitions for fourth level ICMP identifiers 2806087df9eSRuslan Ermilov.It In netinet/udp_var.h 2816087df9eSRuslan Ermilovdefinitions for fourth level UDP identifiers 2826087df9eSRuslan Ermilov.El 2838251b8b8SMateusz Piotrowski.Sh EXIT STATUS 2848251b8b8SMateusz Piotrowski.Ex -std 285dea673e9SRodney W. Grimes.Sh EXAMPLES 286dea673e9SRodney W. GrimesFor example, to retrieve the maximum number of processes allowed 287b91e5f67SSteve Pricein the system, one would use the following request: 288def778b8SRuslan Ermilov.Pp 289def778b8SRuslan Ermilov.Dl "sysctl kern.maxproc" 290dea673e9SRodney W. Grimes.Pp 291dea673e9SRodney W. GrimesTo set the maximum number of processes allowed 292b91e5f67SSteve Priceper uid to 1000, one would use the following request: 293def778b8SRuslan Ermilov.Pp 2947e7cdfa0SYaroslav Tykhiy.Dl "sysctl kern.maxprocperuid=1000" 295dea673e9SRodney W. Grimes.Pp 296dea673e9SRodney W. GrimesInformation about the system clock rate may be obtained with: 297def778b8SRuslan Ermilov.Pp 298def778b8SRuslan Ermilov.Dl "sysctl kern.clockrate" 299dea673e9SRodney W. Grimes.Pp 300d9b1bc77SPhilippe CharnierInformation about the load average history may be obtained with: 301def778b8SRuslan Ermilov.Pp 302def778b8SRuslan Ermilov.Dl "sysctl vm.loadavg" 3031d86b91cSPoul-Henning Kamp.Pp 3041d86b91cSPoul-Henning KampMore variables than these exist, and the best and likely only place 3051d86b91cSPoul-Henning Kampto search for their deeper meaning is undoubtedly the source where 3061d86b91cSPoul-Henning Kampthey are defined. 3072a6bc064SYaroslav Tykhiy.Sh COMPATIBILITY 3082a6bc064SYaroslav TykhiyThe 3092a6bc064SYaroslav Tykhiy.Fl w 3102a6bc064SYaroslav Tykhiyoption has been deprecated and is silently ignored. 311dea673e9SRodney W. Grimes.Sh SEE ALSO 31297a00e76SAlexey Zelkin.Xr sysctl 3 , 31343308797SChristian Brueffer.Xr loader.conf 5 , 31443308797SChristian Brueffer.Xr sysctl.conf 5 , 31543308797SChristian Brueffer.Xr loader 8 316dea673e9SRodney W. Grimes.Sh HISTORY 317629e80efSPhilippe CharnierA 318629e80efSPhilippe Charnier.Nm 319629e80efSPhilippe Charnierutility first appeared in 32085cf659aSMike Pritchard.Bx 4.4 . 3211d86b91cSPoul-Henning Kamp.Pp 32285cf659aSMike PritchardIn 323d9b1bc77SPhilippe Charnier.Fx 2.2 , 324d9b1bc77SPhilippe Charnier.Nm 32585cf659aSMike Pritchardwas significantly remodeled. 3266087df9eSRuslan Ermilov.Sh BUGS 3276087df9eSRuslan ErmilovThe 3286087df9eSRuslan Ermilov.Nm 3296087df9eSRuslan Ermilovutility presently exploits an undocumented interface to the kernel 330*0438e9beSMateusz Piotrowski.Xr sysctl 9 331*0438e9beSMateusz Piotrowskifacility to traverse the sysctl tree and to retrieve format 3326087df9eSRuslan Ermilovand name information. 3336087df9eSRuslan ErmilovThis correct interface is being thought about for the time being. 334