1*7abd0fb2Slogwang.\" Copyright (c) 1993 2*7abd0fb2Slogwang.\" The Regents of the University of California. All rights reserved. 3*7abd0fb2Slogwang.\" 4*7abd0fb2Slogwang.\" Redistribution and use in source and binary forms, with or without 5*7abd0fb2Slogwang.\" modification, are permitted provided that the following conditions 6*7abd0fb2Slogwang.\" are met: 7*7abd0fb2Slogwang.\" 1. Redistributions of source code must retain the above copyright 8*7abd0fb2Slogwang.\" notice, this list of conditions and the following disclaimer. 9*7abd0fb2Slogwang.\" 2. Redistributions in binary form must reproduce the above copyright 10*7abd0fb2Slogwang.\" notice, this list of conditions and the following disclaimer in the 11*7abd0fb2Slogwang.\" documentation and/or other materials provided with the distribution. 12*7abd0fb2Slogwang.\" 4. Neither the name of the University nor the names of its contributors 13*7abd0fb2Slogwang.\" may be used to endorse or promote products derived from this software 14*7abd0fb2Slogwang.\" without specific prior written permission. 15*7abd0fb2Slogwang.\" 16*7abd0fb2Slogwang.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 17*7abd0fb2Slogwang.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18*7abd0fb2Slogwang.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19*7abd0fb2Slogwang.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 20*7abd0fb2Slogwang.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21*7abd0fb2Slogwang.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22*7abd0fb2Slogwang.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23*7abd0fb2Slogwang.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24*7abd0fb2Slogwang.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25*7abd0fb2Slogwang.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26*7abd0fb2Slogwang.\" SUCH DAMAGE. 27*7abd0fb2Slogwang.\" 28*7abd0fb2Slogwang.\" From: @(#)sysctl.8 8.1 (Berkeley) 6/6/93 29*7abd0fb2Slogwang.\" $FreeBSD$ 30*7abd0fb2Slogwang.\" 31*7abd0fb2Slogwang.Dd December 10, 2015 32*7abd0fb2Slogwang.Dt SYSCTL 8 33*7abd0fb2Slogwang.Os 34*7abd0fb2Slogwang.Sh NAME 35*7abd0fb2Slogwang.Nm sysctl 36*7abd0fb2Slogwang.Nd get or set kernel state 37*7abd0fb2Slogwang.Sh SYNOPSIS 38*7abd0fb2Slogwang.Nm 39*7abd0fb2Slogwang.Op Fl bdehiNnoRTtqx 40*7abd0fb2Slogwang.Op Fl B Ar bufsize 41*7abd0fb2Slogwang.Op Fl f Ar filename 42*7abd0fb2Slogwang.Ar name Ns Op = Ns Ar value 43*7abd0fb2Slogwang.Ar ... 44*7abd0fb2Slogwang.Nm 45*7abd0fb2Slogwang.Op Fl bdehNnoRTtqx 46*7abd0fb2Slogwang.Op Fl B Ar bufsize 47*7abd0fb2Slogwang.Fl a 48*7abd0fb2Slogwang.Sh DESCRIPTION 49*7abd0fb2SlogwangThe 50*7abd0fb2Slogwang.Nm 51*7abd0fb2Slogwangutility retrieves kernel state and allows processes with appropriate 52*7abd0fb2Slogwangprivilege to set kernel state. 53*7abd0fb2SlogwangThe state to be retrieved or set is described using a 54*7abd0fb2Slogwang.Dq Management Information Base 55*7abd0fb2Slogwang.Pq Dq MIB 56*7abd0fb2Slogwangstyle name, described as a dotted set of 57*7abd0fb2Slogwangcomponents. 58*7abd0fb2Slogwang.Pp 59*7abd0fb2SlogwangThe following options are available: 60*7abd0fb2Slogwang.Bl -tag -width indent 61*7abd0fb2Slogwang.It Fl A 62*7abd0fb2SlogwangEquivalent to 63*7abd0fb2Slogwang.Fl o a 64*7abd0fb2Slogwang(for compatibility). 65*7abd0fb2Slogwang.It Fl a 66*7abd0fb2SlogwangList all the currently available non-opaque values. 67*7abd0fb2SlogwangThis option is ignored if one or more variable names are specified on 68*7abd0fb2Slogwangthe command line. 69*7abd0fb2Slogwang.It Fl b 70*7abd0fb2SlogwangForce the value of the variable(s) to be output in raw, binary format. 71*7abd0fb2SlogwangNo names are printed and no terminating newlines are output. 72*7abd0fb2SlogwangThis is mostly useful with a single variable. 73*7abd0fb2Slogwang.It Fl B Ar bufsize 74*7abd0fb2SlogwangSet the buffer size to read from the 75*7abd0fb2Slogwang.Nm 76*7abd0fb2Slogwangto 77*7abd0fb2Slogwang.Ar bufsize . 78*7abd0fb2SlogwangThis is necessary for a 79*7abd0fb2Slogwang.Nm 80*7abd0fb2Slogwangthat has variable length, and the probe value of 0 is a valid length, such as 81*7abd0fb2Slogwang.Va kern.arandom . 82*7abd0fb2Slogwang.It Fl d 83*7abd0fb2SlogwangPrint the description of the variable instead of its value. 84*7abd0fb2Slogwang.It Fl e 85*7abd0fb2SlogwangSeparate the name and the value of the variable(s) with 86*7abd0fb2Slogwang.Ql = . 87*7abd0fb2SlogwangThis is useful for producing output which can be fed back to the 88*7abd0fb2Slogwang.Nm 89*7abd0fb2Slogwangutility. 90*7abd0fb2SlogwangThis option is ignored if either 91*7abd0fb2Slogwang.Fl N 92*7abd0fb2Slogwangor 93*7abd0fb2Slogwang.Fl n 94*7abd0fb2Slogwangis specified, or a variable is being set. 95*7abd0fb2Slogwang.It Fl f Ar filename 96*7abd0fb2SlogwangSpecify a file which contains a pair of name and value in each line. 97*7abd0fb2Slogwang.Nm 98*7abd0fb2Slogwangreads and processes the specified file first and then processes the name 99*7abd0fb2Slogwangand value pairs in the command line argument. 100*7abd0fb2Slogwang.It Fl h 101*7abd0fb2SlogwangFormat output for human, rather than machine, readability. 102*7abd0fb2Slogwang.It Fl i 103*7abd0fb2SlogwangIgnore unknown OIDs. 104*7abd0fb2SlogwangThe purpose is to make use of 105*7abd0fb2Slogwang.Nm 106*7abd0fb2Slogwangfor collecting data from a variety of machines (not all of which 107*7abd0fb2Slogwangare necessarily running exactly the same software) easier. 108*7abd0fb2Slogwang.It Fl N 109*7abd0fb2SlogwangShow only variable names, not their values. 110*7abd0fb2SlogwangThis is particularly useful with shells that offer programmable 111*7abd0fb2Slogwangcompletion. 112*7abd0fb2SlogwangTo enable completion of variable names in 113*7abd0fb2Slogwang.Xr zsh 1 Pq Pa ports/shells/zsh , 114*7abd0fb2Slogwanguse the following code: 115*7abd0fb2Slogwang.Bd -literal -offset indent 116*7abd0fb2Slogwanglistsysctls () { set -A reply $(sysctl -AN ${1%.*}) } 117*7abd0fb2Slogwangcompctl -K listsysctls sysctl 118*7abd0fb2Slogwang.Ed 119*7abd0fb2Slogwang.Pp 120*7abd0fb2SlogwangTo enable completion of variable names in 121*7abd0fb2Slogwang.Xr tcsh 1 , 122*7abd0fb2Slogwanguse: 123*7abd0fb2Slogwang.Pp 124*7abd0fb2Slogwang.Dl "complete sysctl 'n/*/`sysctl -Na`/'" 125*7abd0fb2Slogwang.It Fl n 126*7abd0fb2SlogwangShow only variable values, not their names. 127*7abd0fb2SlogwangThis option is useful for setting shell variables. 128*7abd0fb2SlogwangFor instance, to save the pagesize in variable 129*7abd0fb2Slogwang.Va psize , 130*7abd0fb2Slogwanguse: 131*7abd0fb2Slogwang.Pp 132*7abd0fb2Slogwang.Dl "set psize=`sysctl -n hw.pagesize`" 133*7abd0fb2Slogwang.It Fl o 134*7abd0fb2SlogwangShow opaque variables (which are normally suppressed). 135*7abd0fb2SlogwangThe format and length are printed, as well as a hex dump of the first 136*7abd0fb2Slogwangsixteen bytes of the value. 137*7abd0fb2Slogwang.It Fl q 138*7abd0fb2SlogwangSuppress some warnings generated by 139*7abd0fb2Slogwang.Nm 140*7abd0fb2Slogwangto standard error. 141*7abd0fb2Slogwang.It Fl T 142*7abd0fb2SlogwangDisplay only variables that are settable via loader (CTLFLAG_TUN). 143*7abd0fb2Slogwang.It Fl t 144*7abd0fb2SlogwangPrint the type of the variable. 145*7abd0fb2Slogwang.It Fl W 146*7abd0fb2SlogwangDisplay only writable variables that are not statistical. 147*7abd0fb2SlogwangUseful for determining the set of runtime tunable sysctls. 148*7abd0fb2Slogwang.It Fl X 149*7abd0fb2SlogwangEquivalent to 150*7abd0fb2Slogwang.Fl x a 151*7abd0fb2Slogwang(for compatibility). 152*7abd0fb2Slogwang.It Fl x 153*7abd0fb2SlogwangAs 154*7abd0fb2Slogwang.Fl o , 155*7abd0fb2Slogwangbut prints a hex dump of the entire value instead of just the first 156*7abd0fb2Slogwangfew bytes. 157*7abd0fb2Slogwang.El 158*7abd0fb2Slogwang.Pp 159*7abd0fb2SlogwangThe information available from 160*7abd0fb2Slogwang.Nm 161*7abd0fb2Slogwangconsists of integers, strings, and opaque types. 162*7abd0fb2SlogwangThe 163*7abd0fb2Slogwang.Nm 164*7abd0fb2Slogwangutility 165*7abd0fb2Slogwangonly knows about a couple of opaque types, and will resort to hexdumps 166*7abd0fb2Slogwangfor the rest. 167*7abd0fb2SlogwangThe opaque information is much more useful if retrieved by special 168*7abd0fb2Slogwangpurpose programs such as 169*7abd0fb2Slogwang.Xr ps 1 , 170*7abd0fb2Slogwang.Xr systat 1 , 171*7abd0fb2Slogwangand 172*7abd0fb2Slogwang.Xr netstat 1 . 173*7abd0fb2Slogwang.Pp 174*7abd0fb2SlogwangSome of the variables which cannot be modified during normal system 175*7abd0fb2Slogwangoperation can be initialized via 176*7abd0fb2Slogwang.Xr loader 8 177*7abd0fb2Slogwangtunables. 178*7abd0fb2SlogwangThis can for example be done by setting them in 179*7abd0fb2Slogwang.Xr loader.conf 5 . 180*7abd0fb2SlogwangPlease refer to 181*7abd0fb2Slogwang.Xr loader.conf 5 182*7abd0fb2Slogwangfor more information on which tunables are available and how to set them. 183*7abd0fb2Slogwang.Pp 184*7abd0fb2SlogwangThe string and integer information is summarized below. 185*7abd0fb2SlogwangFor a detailed description of these variable see 186*7abd0fb2Slogwang.Xr sysctl 3 . 187*7abd0fb2Slogwang.Pp 188*7abd0fb2SlogwangThe changeable column indicates whether a process with appropriate 189*7abd0fb2Slogwangprivilege can change the value. 190*7abd0fb2SlogwangString and integer values can be set using 191*7abd0fb2Slogwang.Nm . 192*7abd0fb2Slogwang.Bl -column security.bsd.unprivileged_read_msgbuf integerxxx 193*7abd0fb2Slogwang.It Sy "Name Type Changeable" 194*7abd0fb2Slogwang.It "kern.ostype string no" 195*7abd0fb2Slogwang.It "kern.osrelease string no" 196*7abd0fb2Slogwang.It "kern.osrevision integer no" 197*7abd0fb2Slogwang.It "kern.version string no" 198*7abd0fb2Slogwang.It "kern.maxvnodes integer yes" 199*7abd0fb2Slogwang.It "kern.maxproc integer no" 200*7abd0fb2Slogwang.It "kern.maxprocperuid integer yes" 201*7abd0fb2Slogwang.It "kern.maxfiles integer yes" 202*7abd0fb2Slogwang.It "kern.maxfilesperproc integer yes" 203*7abd0fb2Slogwang.It "kern.argmax integer no" 204*7abd0fb2Slogwang.It "kern.securelevel integer raise only" 205*7abd0fb2Slogwang.It "kern.hostname string yes" 206*7abd0fb2Slogwang.It "kern.hostid integer yes" 207*7abd0fb2Slogwang.It "kern.clockrate struct no" 208*7abd0fb2Slogwang.It "kern.posix1version integer no" 209*7abd0fb2Slogwang.It "kern.ngroups integer no" 210*7abd0fb2Slogwang.It "kern.job_control integer no" 211*7abd0fb2Slogwang.It "kern.saved_ids integer no" 212*7abd0fb2Slogwang.It "kern.boottime struct no" 213*7abd0fb2Slogwang.It "kern.domainname string yes" 214*7abd0fb2Slogwang.It "kern.filedelay integer yes" 215*7abd0fb2Slogwang.It "kern.dirdelay integer yes" 216*7abd0fb2Slogwang.It "kern.metadelay integer yes" 217*7abd0fb2Slogwang.It "kern.osreldate string no" 218*7abd0fb2Slogwang.It "kern.bootfile string yes" 219*7abd0fb2Slogwang.It "kern.corefile string yes" 220*7abd0fb2Slogwang.It "kern.logsigexit integer yes" 221*7abd0fb2Slogwang.It "security.bsd.suser_enabled integer yes" 222*7abd0fb2Slogwang.It "security.bsd.see_other_uids integer yes" 223*7abd0fb2Slogwang.It "security.bsd.unprivileged_proc_debug integer yes" 224*7abd0fb2Slogwang.It "security.bsd.unprivileged_read_msgbuf integer yes" 225*7abd0fb2Slogwang.It "vm.loadavg struct no" 226*7abd0fb2Slogwang.It "hw.machine string no" 227*7abd0fb2Slogwang.It "hw.model string no" 228*7abd0fb2Slogwang.It "hw.ncpu integer no" 229*7abd0fb2Slogwang.It "hw.byteorder integer no" 230*7abd0fb2Slogwang.It "hw.physmem integer no" 231*7abd0fb2Slogwang.It "hw.usermem integer no" 232*7abd0fb2Slogwang.It "hw.pagesize integer no" 233*7abd0fb2Slogwang.It "hw.floatingpoint integer no" 234*7abd0fb2Slogwang.It "hw.machine_arch string no" 235*7abd0fb2Slogwang.It "hw.realmem integer no" 236*7abd0fb2Slogwang.It "machdep.adjkerntz integer yes" 237*7abd0fb2Slogwang.It "machdep.disable_rtc_set integer yes" 238*7abd0fb2Slogwang.It "machdep.guessed_bootdev string no" 239*7abd0fb2Slogwang.It "user.cs_path string no" 240*7abd0fb2Slogwang.It "user.bc_base_max integer no" 241*7abd0fb2Slogwang.It "user.bc_dim_max integer no" 242*7abd0fb2Slogwang.It "user.bc_scale_max integer no" 243*7abd0fb2Slogwang.It "user.bc_string_max integer no" 244*7abd0fb2Slogwang.It "user.coll_weights_max integer no" 245*7abd0fb2Slogwang.It "user.expr_nest_max integer no" 246*7abd0fb2Slogwang.It "user.line_max integer no" 247*7abd0fb2Slogwang.It "user.re_dup_max integer no" 248*7abd0fb2Slogwang.It "user.posix2_version integer no" 249*7abd0fb2Slogwang.It "user.posix2_c_bind integer no" 250*7abd0fb2Slogwang.It "user.posix2_c_dev integer no" 251*7abd0fb2Slogwang.It "user.posix2_char_term integer no" 252*7abd0fb2Slogwang.It "user.posix2_fort_dev integer no" 253*7abd0fb2Slogwang.It "user.posix2_fort_run integer no" 254*7abd0fb2Slogwang.It "user.posix2_localedef integer no" 255*7abd0fb2Slogwang.It "user.posix2_sw_dev integer no" 256*7abd0fb2Slogwang.It "user.posix2_upe integer no" 257*7abd0fb2Slogwang.It "user.stream_max integer no" 258*7abd0fb2Slogwang.It "user.tzname_max integer no" 259*7abd0fb2Slogwang.El 260*7abd0fb2Slogwang.Sh FILES 261*7abd0fb2Slogwang.Bl -tag -width ".In netinet/icmp_var.h" -compact 262*7abd0fb2Slogwang.It In sys/sysctl.h 263*7abd0fb2Slogwangdefinitions for top level identifiers, second level kernel and hardware 264*7abd0fb2Slogwangidentifiers, and user level identifiers 265*7abd0fb2Slogwang.It In sys/socket.h 266*7abd0fb2Slogwangdefinitions for second level network identifiers 267*7abd0fb2Slogwang.It In sys/gmon.h 268*7abd0fb2Slogwangdefinitions for third level profiling identifiers 269*7abd0fb2Slogwang.It In vm/vm_param.h 270*7abd0fb2Slogwangdefinitions for second level virtual memory identifiers 271*7abd0fb2Slogwang.It In netinet/in.h 272*7abd0fb2Slogwangdefinitions for third level Internet identifiers and 273*7abd0fb2Slogwangfourth level IP identifiers 274*7abd0fb2Slogwang.It In netinet/icmp_var.h 275*7abd0fb2Slogwangdefinitions for fourth level ICMP identifiers 276*7abd0fb2Slogwang.It In netinet/udp_var.h 277*7abd0fb2Slogwangdefinitions for fourth level UDP identifiers 278*7abd0fb2Slogwang.El 279*7abd0fb2Slogwang.Sh EXAMPLES 280*7abd0fb2SlogwangFor example, to retrieve the maximum number of processes allowed 281*7abd0fb2Slogwangin the system, one would use the following request: 282*7abd0fb2Slogwang.Pp 283*7abd0fb2Slogwang.Dl "sysctl kern.maxproc" 284*7abd0fb2Slogwang.Pp 285*7abd0fb2SlogwangTo set the maximum number of processes allowed 286*7abd0fb2Slogwangper uid to 1000, one would use the following request: 287*7abd0fb2Slogwang.Pp 288*7abd0fb2Slogwang.Dl "sysctl kern.maxprocperuid=1000" 289*7abd0fb2Slogwang.Pp 290*7abd0fb2SlogwangInformation about the system clock rate may be obtained with: 291*7abd0fb2Slogwang.Pp 292*7abd0fb2Slogwang.Dl "sysctl kern.clockrate" 293*7abd0fb2Slogwang.Pp 294*7abd0fb2SlogwangInformation about the load average history may be obtained with: 295*7abd0fb2Slogwang.Pp 296*7abd0fb2Slogwang.Dl "sysctl vm.loadavg" 297*7abd0fb2Slogwang.Pp 298*7abd0fb2SlogwangMore variables than these exist, and the best and likely only place 299*7abd0fb2Slogwangto search for their deeper meaning is undoubtedly the source where 300*7abd0fb2Slogwangthey are defined. 301*7abd0fb2Slogwang.Sh COMPATIBILITY 302*7abd0fb2SlogwangThe 303*7abd0fb2Slogwang.Fl w 304*7abd0fb2Slogwangoption has been deprecated and is silently ignored. 305*7abd0fb2Slogwang.Sh SEE ALSO 306*7abd0fb2Slogwang.Xr sysctl 3 , 307*7abd0fb2Slogwang.Xr loader.conf 5 , 308*7abd0fb2Slogwang.Xr sysctl.conf 5 , 309*7abd0fb2Slogwang.Xr loader 8 310*7abd0fb2Slogwang.Sh HISTORY 311*7abd0fb2SlogwangA 312*7abd0fb2Slogwang.Nm 313*7abd0fb2Slogwangutility first appeared in 314*7abd0fb2Slogwang.Bx 4.4 . 315*7abd0fb2Slogwang.Pp 316*7abd0fb2SlogwangIn 317*7abd0fb2Slogwang.Fx 2.2 , 318*7abd0fb2Slogwang.Nm 319*7abd0fb2Slogwangwas significantly remodeled. 320*7abd0fb2Slogwang.Sh BUGS 321*7abd0fb2SlogwangThe 322*7abd0fb2Slogwang.Nm 323*7abd0fb2Slogwangutility presently exploits an undocumented interface to the kernel 324*7abd0fb2Slogwangsysctl facility to traverse the sysctl tree and to retrieve format 325*7abd0fb2Slogwangand name information. 326*7abd0fb2SlogwangThis correct interface is being thought about for the time being. 327