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. All advertising materials mentioning features or use of this software 13.\" must display the following acknowledgement: 14.\" This product includes software developed by the University of 15.\" California, Berkeley and its contributors. 16.\" 4. Neither the name of the University nor the names of its contributors 17.\" may be used to endorse or promote products derived from this software 18.\" without specific prior written permission. 19.\" 20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30.\" SUCH DAMAGE. 31.\" 32.\" From: @(#)sysctl.8 8.1 (Berkeley) 6/6/93 33.\" $Id: sysctl.8,v 1.7 1995/12/21 12:39:24 phk Exp $ 34.\" 35.Dd September 23, 1994 36.Dt SYSCTL 8 37.Os 38.Sh NAME 39.Nm sysctl 40.Nd get or set kernel state 41.Sh SYNOPSIS 42.Nm sysctl 43.Op Fl bn 44.Ar name ... 45.Nm sysctl 46.Op Fl bn 47.Fl w 48.Ar name=value ... 49.Nm sysctl 50.Op Fl bn 51.Fl aAX 52.Sh DESCRIPTION 53The 54.Nm sysctl 55utility retrieves kernel state and allows processes with 56appropriate privilege to set kernel state. 57The state to be retrieved or set is described using a 58``Management Information Base'' (``MIB'') style name, 59described as a dotted set of components. 60.Pp 61The 62.Fl a 63flag can be used to list all the currently available string or integer values. 64.Pp 65The 66.Fl A 67flag will list all the known MIB names including opaques. 68Those with string or integer values will be printed as with the 69.Fl a 70flag; for the opaque values, 71information about the format and the length is printed in addition the first 72few bytes is dumped in hex. 73.Pp 74The 75.Fl X 76flag is the same as 77.Fl A 78except the entire value of opaque variables is hexdumped. 79.Pp 80The 81.Fl n 82flag specifies that the printing of the field name should be 83suppressed and that only its value should be output. 84This flag is useful for setting shell variables. 85For example, to save the pagesize in variable psize, use: 86.Bd -literal -offset indent -compact 87set psize=`sysctl -n hw.pagesize` 88.Ed 89.Pp 90The 91.Fl b 92flag forces the value of the variable(s) to be output in raw, binary 93format. No names are printed and no terminating newlines are output. 94This is mostly useful with a single variable. 95.Pp 96If just a MIB style name is given, 97the corresponding value is retrieved. 98If a value is to be set, the 99.Fl w 100flag must be specified and the MIB name followed 101by an equal sign and the new value to be used. 102.Pp 103The information available from 104.Nm sysctl 105consists of integers, strings, and opaques. 106.Nm sysctl 107only knows about a couple of opaque types, and will resort to hexdumps 108for the rest. 109The opaque information is much more useful if retrieved by special 110purpose programs such as 111.Nm ps , 112.Nm systat , 113and 114.Nm netstat . 115.Pp 116The string and integer information is summarized below. 117For a detailed description of these variable see 118.Xr sysctl 3 . 119.Pp 120The changeable column indicates whether a process with appropriate 121privilege can change the value. 122.Bl -column net.inet.ip.forwardingxxxxxx integerxxx 123.It Sy Name Type Changeable 124.It kern.ostype string no 125.It kern.osrelease string no 126.It kern.osrevision integer no 127.It kern.version string no 128.It kern.maxvnodes integer yes 129.It kern.maxproc integer yes 130.It kern.maxprocperuid integer yes 131.It kern.maxfiles integer yes 132.It kern.maxfilesperproc integer yes 133.It kern.argmax integer no 134.It kern.securelevel integer raise only 135.It kern.hostname string yes 136.It kern.hostid integer yes 137.It kern.clockrate struct no 138.It kern.posix1version integer no 139.It kern.ngroups integer no 140.It kern.job_control integer no 141.It kern.saved_ids integer no 142.It kern.link_max integer no 143.It kern.max_canon integer no 144.It kern.max_input integer no 145.It kern.name_max integer no 146.It kern.path_max integer no 147.It kern.pipe_buf integer no 148.It kern.chown_restricted integer no 149.It kern.no_trunc integer no 150.It kern.vdisable integer no 151.It kern.boottime struct no 152.It kern.domainname string yes 153.It kern.update integer yes 154.It kern.osreldate string no 155.It kern.bootfile string yes 156.It vm.loadavg struct no 157.It hw.machine string no 158.It hw.model string no 159.It hw.ncpu integer no 160.It hw.byteorder integer no 161.It hw.physmem integer no 162.It hw.usermem integer no 163.It hw.pagesize integer no 164.It hw.floatingpoint integer no 165.It machdep.console_device dev_t no 166.It machdep.adjkerntz integer yes 167.It machdep.disable_rtc_set integer yes 168.It user.cs_path string no 169.It user.bc_base_max integer no 170.It user.bc_dim_max integer no 171.It user.bc_scale_max integer no 172.It user.bc_string_max integer no 173.It user.coll_weights_max integer no 174.It user.expr_nest_max integer no 175.It user.line_max integer no 176.It user.re_dup_max integer no 177.It user.posix2_version integer no 178.It user.posix2_c_bind integer no 179.It user.posix2_c_dev integer no 180.It user.posix2_char_term integer no 181.It user.posix2_fort_dev integer no 182.It user.posix2_fort_run integer no 183.It user.posix2_localedef integer no 184.It user.posix2_sw_dev integer no 185.It user.posix2_upe integer no 186.El 187.Sh EXAMPLES 188.Pp 189For example, to retrieve the maximum number of processes allowed 190in the system, one would use the follow request: 191.Bd -literal -offset indent -compact 192sysctl kern.maxproc 193.Ed 194.Pp 195To set the maximum number of processes allowed 196in the system to 1000, one would use the follow request: 197.Bd -literal -offset indent -compact 198sysctl -w kern.maxproc=1000 199.Ed 200.Pp 201Information about the system clock rate may be obtained with: 202.Bd -literal -offset indent -compact 203sysctl kern.clockrate 204.Ed 205.Pp 206Information about the load average history may be obtained with 207.Bd -literal -offset indent -compact 208sysctl vm.loadavg 209.Ed 210.Pp 211More variables than these exist, and the best and likely only place 212to search for their deeper meaning is undoubtedly the source where 213they are defined. 214.Sh FILES 215.Bl -tag -width <netinet/icmpXvar.h> -compact 216.It Pa <sys/sysctl.h> 217definitions for top level identifiers, second level kernel and hardware 218identifiers, and user level identifiers 219.It Pa <sys/socket.h> 220definitions for second level network identifiers 221.It Pa <sys/gmon.h> 222definitions for third level profiling identifiers 223.It Pa <vm/vm_param.h> 224definitions for second level virtual memory identifiers 225.It Pa <netinet/in.h> 226definitions for third level Internet identifiers and 227fourth level IP identifiers 228.It Pa <netinet/icmp_var.h> 229definitions for fourth level ICMP identifiers 230.It Pa <netinet/udp_var.h> 231definitions for fourth level UDP identifiers 232.El 233.Sh SEE ALSO 234.Xr sysctl 3 235.Sh BUGS 236.Nm sysctl 237presently exploits an undocumented interface to the kernel 238sysctl facility to traverse the sysctl tree and to retrieve format 239and name information. 240This correct interface is being thought about for the time being. 241.Sh HISTORY 242.Nm sysctl 243first appeared in 4.4BSD. 244.Pp 245In FreeBSD 2.2 sysctl was significantly remodeled. 246