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