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.\" $DragonFly: src/sbin/sysctl/sysctl.8,v 1.7 2007/10/02 12:57:00 hasso Exp $ 31.\" 32.Dd February 3, 2011 33.Dt SYSCTL 8 34.Os 35.Sh NAME 36.Nm sysctl 37.Nd get or set kernel state 38.Sh SYNOPSIS 39.Nm 40.Op Fl bdeNnox 41.Ar name Ns Op = Ns Ar value 42.Ar ... 43.Nm 44.Op Fl bdeNnox 45.Fl a 46.Sh DESCRIPTION 47The 48.Nm 49utility retrieves kernel state and allows processes with appropriate 50privilege to set kernel state. 51The state to be retrieved or set is described using a 52.Dq Management Information Base 53.Pq Dq MIB 54style name, described as a dotted set of 55components. 56.Pp 57The following options are available: 58.Bl -tag -width indent 59.It Fl A 60Equivalent to 61.Fl o a 62(for compatibility). 63.It Fl a 64List all the currently available non-opaque values. 65This option is ignored if one or more variable names are specified on 66the command line. 67.It Fl b 68Force the value of the variable(s) to be output in raw, binary format. 69No names are printed and no terminating newlines are output. 70This is mostly useful with a single variable. 71.It Fl d 72Print the description of the variable instead of its value. 73.It Fl e 74Separate the name and the value of the variable(s) with 75.Ql = . 76This is useful for producing output which can be fed back to the 77.Nm 78utility. 79This option is ignored if either 80.Fl N 81or 82.Fl n 83is specified, or a variable is being set. 84.It Fl N 85Show only variable names, not their values. 86This is particularly useful with shells that offer programmable 87completion. 88To enable completion of variable names in 89.Nm zsh , 90use the following code: 91.Bd -literal -offset indent 92listsysctls () { set -A reply $(sysctl -AN ${1%.*}) } 93compctl -K listsysctls sysctl 94.Ed 95.It Fl n 96Show only variable values, not their names. 97This option is useful for setting shell variables. 98For instance, to save the pagesize in variable 99.Va psize , 100use: 101.Pp 102.Dl "set psize=`sysctl -n hw.pagesize`" 103.It Fl o 104Show opaque variables (which are normally suppressed). 105The format and length are printed, as well as a hex dump of the first 106sixteen bytes of the value. 107.It Fl X 108Equivalent to 109.Fl x a 110(for compatibility). 111.It Fl x 112As 113.Fl o , 114but prints a hex dump of the entire value instead of just the first 115few bytes. 116.El 117.Pp 118The information available from 119.Nm 120consists of integers, strings, devices 121.Pq Vt udev_t , 122and opaque types. 123The 124.Nm 125utility 126only knows about a couple of opaque types, and will resort to hexdumps 127for the rest. 128The opaque information is much more useful if retrieved by special 129purpose programs such as 130.Nm ps , 131.Nm systat 132and 133.Nm netstat . 134.Pp 135Some of the variables which cannot be modified during normal system 136operation can be initialized via 137.Xr loader 8 138tunables. 139This can for example be done by setting them in 140.Xr loader.conf 5 . 141Please refer to 142.Xr loader.conf 5 143for more information on which tunables are available and how to set them. 144.Pp 145The string and integer information is summarized below. 146For a detailed description of these variable see 147.Xr sysctl 3 . 148.Pp 149The changeable column indicates whether a process with appropriate 150privilege can change the value. 151String, integer, and devices values can be set using 152.Nm . 153For device values, 154.Cm value 155can be specified as a character device special file name. 156Special values 157.Cm off 158and 159.Ar none 160denote 161.Dq no device . 162.Bl -column net.inet.ip.forwardingxxxxxx integerxxx 163.It Sy "Name Type Changeable" 164.It "kern.ostype string no" 165.It "kern.osrelease string no" 166.It "kern.osrevision integer no" 167.It "kern.version string no" 168.It "kern.maxvnodes integer yes" 169.It "kern.maxproc integer no" 170.It "kern.maxprocperuid integer yes" 171.It "kern.maxfiles integer yes" 172.It "kern.maxfilesperproc integer yes" 173.It "kern.argmax integer no" 174.It "kern.securelevel integer raise only" 175.It "kern.hostname string yes" 176.It "kern.hostid integer yes" 177.It "kern.clockrate struct no" 178.It "kern.posix1version integer no" 179.It "kern.ngroups integer no" 180.It "kern.job_control integer no" 181.It "kern.saved_ids integer no" 182.It "kern.boottime struct no" 183.It "kern.domainname string yes" 184.It "kern.filedelay integer yes" 185.It "kern.dirdelay integer yes" 186.It "kern.metadelay integer yes" 187.It "kern.osreldate string no" 188.It "kern.bootfile string yes" 189.It "kern.corefile string yes" 190.It "kern.dumpdev udev_t yes" 191.It "kern.logsigexit integer yes" 192.It "vm.loadavg struct no" 193.It "hw.machine string no" 194.It "hw.model string no" 195.It "hw.ncpu integer no" 196.It "hw.byteorder integer no" 197.It "hw.physmem long no" 198.It "hw.usermem integer no" 199.It "hw.pagesize integer no" 200.It "hw.floatingpoint integer no" 201.It "hw.machine_arch string no" 202.It "hw.sensors.<xname>.<type><numt> struct no" 203.It "machdep.console_device udev_t no" 204.It "machdep.adjkerntz integer yes" 205.It "machdep.disable_rtc_set integer yes" 206.It "user.cs_path string no" 207.It "user.bc_base_max integer no" 208.It "user.bc_dim_max integer no" 209.It "user.bc_scale_max integer no" 210.It "user.bc_string_max integer no" 211.It "user.coll_weights_max integer no" 212.It "user.expr_nest_max integer no" 213.It "user.line_max integer no" 214.It "user.re_dup_max integer no" 215.It "user.posix2_version integer no" 216.It "user.posix2_c_bind integer no" 217.It "user.posix2_c_dev integer no" 218.It "user.posix2_char_term integer no" 219.It "user.posix2_fort_dev integer no" 220.It "user.posix2_fort_run integer no" 221.It "user.posix2_localedef integer no" 222.It "user.posix2_sw_dev integer no" 223.It "user.posix2_upe integer no" 224.It "user.stream_max integer no" 225.It "user.tzname_max integer no" 226.El 227.Sh FILES 228.Bl -tag -width ".In netinet/icmp_var.h" -compact 229.It In sys/sysctl.h 230definitions for top level identifiers, second level kernel and hardware 231identifiers, and user level identifiers 232.It In sys/socket.h 233definitions for second level network identifiers 234.It In sys/gmon.h 235definitions for third level profiling identifiers 236.It In vm/vm_param.h 237definitions for second level virtual memory identifiers 238.It In netinet/in.h 239definitions for third level Internet identifiers and 240fourth level IP identifiers 241.It In netinet/icmp_var.h 242definitions for fourth level ICMP identifiers 243.It In netinet/udp_var.h 244definitions for fourth level UDP identifiers 245.El 246.Sh EXAMPLES 247For example, to retrieve the maximum number of processes allowed 248in the system, one would use the following request: 249.Pp 250.Dl "sysctl kern.maxproc" 251.Pp 252To set the maximum number of processes allowed 253per uid to 1000, one would use the following request: 254.Pp 255.Dl "sysctl kern.maxprocperuid=1000" 256.Pp 257The device used for crash dumps can be specified using: 258.Pp 259.Dl "sysctl kern.dumpdev=/dev/somedev" 260.Pp 261which is equivalent to 262.Pp 263.Dl "dumpon /dev/somedev" 264.Pp 265Information about the system clock rate may be obtained with: 266.Pp 267.Dl "sysctl kern.clockrate" 268.Pp 269Information about the load average history may be obtained with: 270.Pp 271.Dl "sysctl vm.loadavg" 272.Pp 273More variables than these exist, and the best and likely only place 274to search for their deeper meaning is undoubtedly the source where 275they are defined. 276.Sh COMPATIBILITY 277The 278.Fl w 279option has been deprecated and is silently ignored. 280.Sh SEE ALSO 281.Xr sysctl 3 , 282.Xr loader.conf 5 , 283.Xr sysctl.conf 5 , 284.Xr loader 8 285.Sh HISTORY 286A 287.Nm 288utility first appeared in 289.Bx 4.4 . 290.Pp 291In 292.Fx 2.2 , 293.Nm 294was significantly remodeled. 295.Sh BUGS 296The 297.Nm 298utility presently exploits an undocumented interface to the kernel 299sysctl facility to traverse the sysctl tree and to retrieve format 300and name information. 301This correct interface is being thought about for the time being. 302