1.\" $NetBSD: sysctl.8,v 1.45 2000/03/12 22:56:48 tsarna Exp $ 2.\" 3.\" Copyright (c) 1993 4.\" The Regents of the University of California. All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. All advertising materials mentioning features or use of this software 15.\" must display the following acknowledgement: 16.\" This product includes software developed by the University of 17.\" California, Berkeley and its contributors. 18.\" 4. Neither the name of the University nor the names of its contributors 19.\" may be used to endorse or promote products derived from this software 20.\" without specific prior written permission. 21.\" 22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32.\" SUCH DAMAGE. 33.\" 34.\" @(#)sysctl.8 8.1 (Berkeley) 6/6/93 35.\" 36.Dd June 6, 1993 37.Dt SYSCTL 8 38.Os 39.Sh NAME 40.Nm sysctl 41.Nd get or set kernel state 42.Sh SYNOPSIS 43.Nm sysctl 44.Op Fl n 45.Ar name ... 46.Nm sysctl 47.Op Fl n 48.Fl w 49.Ar name=value ... 50.Nm sysctl 51.Op Fl n 52.Fl aA 53.Nm sysctl 54.Op Fl n 55.Fl f 56.Ar file 57.Sh DESCRIPTION 58The 59.Nm sysctl 60utility retrieves kernel state and allows processes with 61appropriate privilege to set kernel state. 62The state to be retrieved or set is described using a 63``Management Information Base'' (``MIB'') style name, 64described as a dotted set of components. 65The 66.Fl a 67flag can be used to list all the currently available string or integer values. 68The 69.Fl A 70flag will list all the known MIB names including tables. 71Those with string or integer values will be printed as with the 72.Fl a 73flag; for the table values, 74the name of the utility to retrieve them is given. 75.Pp 76The 77.Fl n 78flag specifies that the printing of the field name should be 79suppressed and that only its value should be output. 80This flag is useful for setting shell variables. 81For example, to save the pagesize in variable psize, use: 82.Bd -literal -offset indent -compact 83set psize=`sysctl -n hw.pagesize` 84.Ed 85.Pp 86If just a MIB style name is given, 87the corresponding value is retrieved. 88If a value is to be set, the 89.Fl w 90flag must be specified and the MIB name followed 91by an equal sign and the new value to be used. 92.Pp 93The 94.Fl f 95flag specifies the name of a file to read and process. Blank lines and 96comments (beginning with ``#'') are ignored. Line continuations with 97``\\'' are permitted. Remaining lines are processed similarly to 98command line arguments of the form 99.Ar name 100or 101.Ar name=value . 102The 103.Fl w 104flag is implied by 105.Fl f . 106.Pp 107The proc top-level MIB has a special semantic: it represent per-process values 108and as such may differ from one process to another. The second-level name 109is the pid of the process (in decimal form), or the special word 'curproc'. 110For variables below 'proc.<pid>.rlimit', the integer value may be remplaced 111with the string 'unlimited' if it matches the magic value used to disable 112a limit. 113.Pp 114The information available from 115.Nm sysctl 116consists of integers, strings, and tables. 117The tabular information can only be retrieved by special 118purpose programs such as 119.Nm ps , 120.Nm systat , 121and 122.Nm netstat . 123The string and integer information is summarized below. 124For a detailed description of these variable see 125.Xr sysctl 3 . 126The changeable column indicates whether a process with appropriate 127privilege can change the value. 128.Bl -column net.inet6.tcp6.syn_cache_intervalxxxxxx integerxxx 129.It Sy Name Type Changeable 130.It ddb.fromconsole integer yes 131.It ddb.lines integer yes 132.It ddb.maxoff integer yes 133.It ddb.maxwidth integer yes 134.It ddb.onpanic integer yes 135.It ddb.radix integer yes 136.It ddb.tabstops integer yes 137.It hw.alignbytes integer no 138.It hw.byteorder integer no 139.\".It hw.disknames struct no 140.\".It hw.diskstats struct no 141.It hw.machine string no 142.It hw.machine_arch string no 143.It hw.model string no 144.It hw.ncpu integer no 145.It hw.pagesize integer no 146.It hw.physmem integer no 147.It hw.usermem integer no 148.It kern.argmax integer no 149.It kern.autonicetime integer yes 150.It kern.autoniceval integer yes 151.It kern.boottime struct no 152.It kern.chown_restricted integer no 153.It kern.clockrate struct no 154.It kern.defcorename string yes 155.It kern.fsync integer no 156.It kern.hostid integer yes 157.It kern.hostname string yes 158.It kern.iov_max integer no 159.It kern.job_control integer no 160.It kern.link_max integer no 161.It kern.logsigexit integer yes 162.It kern.max_canon integer no 163.It kern.max_input integer no 164.It kern.maxfiles integer yes 165.It kern.maxpartitions integer no 166.It kern.maxproc integer yes 167.It kern.maxvnodes integer yes 168.It kern.mbuf.mblowat integer yes 169.It kern.mbuf.mcllowat integer yes 170.It kern.mbuf.mclsize integer no 171.It kern.mbuf.msize integer no 172.It kern.mbuf.nmbclusters integer raise only 173.It kern.msgbufsize integer no 174.It kern.name_max integer no 175.It kern.ngroups integer no 176.It kern.no_trunc integer no 177.It kern.osrelease string no 178.It kern.osrevision integer no 179.It kern.ostype string no 180.It kern.path_max integer no 181.It kern.pipe_buf integer no 182.It kern.posix1version integer no 183.It kern.rawpartition integer no 184.It kern.saved_ids integer no 185.It kern.securelevel integer raise only 186.It kern.synchronized_io integer no 187.It kern.sysvmsg integer no 188.It kern.sysvsem integer no 189.It kern.sysvshm integer no 190.It kern.vdisable integer no 191.It kern.version string no 192.It machdep.console_device dev_t no 193.It net.inet.icmp.errratelimit integer yes 194.It net.inet.icmp.maskrepl integer yes 195.It net.inet.ip.allowsrcrt integer yes 196.It net.inet.ip.anonportmax integer yes 197.It net.inet.ip.anonportmin integer yes 198.It net.inet.ip.directed-broadcast integer yes 199.It net.inet.ip.forwarding integer yes 200.It net.inet.ip.forwsrcrt integer yes 201.It net.inet.ip.mtudisc integer yes 202.It net.inet.ip.mtudisctimeout integer yes 203.It net.inet.ip.redirect integer yes 204.It net.inet.ip.subnetsarelocal integer yes 205.It net.inet.ip.ttl integer yes 206.It net.inet.ipsec.ah_cleartos integer yes 207.It net.inet.ipsec.ah_net_deflev integer yes 208.It net.inet.ipsec.ah_offsetmask integer yes 209.It net.inet.ipsec.ah_trans_deflev integer yes 210.It net.inet.ipsec.def_policy integer yes 211.It net.inet.ipsec.dfbit integer yes 212.It net.inet.ipsec.ecn integer yes 213.It net.inet.ipsec.esp_net_deflev integer yes 214.It net.inet.ipsec.esp_trans_deflev integer yes 215.It net.inet.ipsec.inbound_call_ike integer yes 216.It net.inet.tcp.ack_on_push integer yes 217.It net.inet.tcp.compat_42 integer yes 218.It net.inet.tcp.cwm integer yes 219.It net.inet.tcp.cwm_burstsize integer yes 220.It net.inet.tcp.init_win integer yes 221.It net.inet.tcp.init_win integer yes 222.It net.inet.tcp.keepcnt integer yes 223.It net.inet.tcp.keepidle integer yes 224.It net.inet.tcp.keepintvl integer yes 225.It net.inet.tcp.log_refused integer yes 226.It net.inet.tcp.mss_ifmtu integer yes 227.It net.inet.tcp.mssdflt integer yes 228.It net.inet.tcp.recvspace integer yes 229.It net.inet.tcp.rfc1323 integer yes 230.It net.inet.tcp.rstratelimit integer yes 231.It net.inet.tcp.sack integer yes 232.It net.inet.tcp.sendspace integer yes 233.It net.inet.tcp.slowhz integer no 234.It net.inet.tcp.syn_bucket_limit integer yes 235.It net.inet.tcp.syn_cache_interval integer yes 236.It net.inet.tcp.syn_cache_limit integer yes 237.It net.inet.tcp.timestamps integer yes 238.It net.inet.tcp.win_scale integer yes 239.It net.inet.udp.checksum integer yes 240.It net.inet.udp.recvspace integer yes 241.It net.inet.udp.sendspace integer yes 242.It net.inet6.icmp6.errratelimit integer yes 243.It net.inet6.icmp6.nd6_delay integer yes 244.It net.inet6.icmp6.nd6_mmaxtries integer yes 245.It net.inet6.icmp6.nd6_prune integer yes 246.It net.inet6.icmp6.nd6_umaxtries integer yes 247.It net.inet6.icmp6.nd6_useloopback integer yes 248.It net.inet6.icmp6.nodeinfo integer yes 249.It net.inet6.icmp6.rediraccept integer yes 250.It net.inet6.icmp6.redirtimeout integer yes 251.It net.inet6.ip6.accept_rtadv integer yes 252.It net.inet6.ip6.auto_flowlabel integer yes 253.It net.inet6.ip6.bindv6only integer yes 254.It net.inet6.ip6.dad_count integer yes 255.It net.inet6.ip6.defmcasthlim integer yes 256.It net.inet6.ip6.forwarding integer yes 257.It net.inet6.ip6.gif_hlim integer yes 258.It net.inet6.ip6.hdrnestlimit integer yes 259.It net.inet6.ip6.hlim integer yes 260.It net.inet6.ip6.kame_version string no 261.It net.inet6.ip6.keepfaith integer yes 262.It net.inet6.ip6.log_interval integer yes 263.It net.inet6.ip6.maxfragpackets integer yes 264.It net.inet6.ip6.redirect integer yes 265.It net.inet6.ip6.rr_prune integer yes 266.It net.inet6.ip6.use_deprecated integer yes 267.It net.inet6.ipsec6.ah_net_deflev integer yes 268.It net.inet6.ipsec6.ah_trans_deflev integer yes 269.It net.inet6.ipsec6.def_policy integer yes 270.It net.inet6.ipsec6.ecn integer yes 271.It net.inet6.ipsec6.esp_net_deflev integer yes 272.It net.inet6.ipsec6.esp_trans_deflev integer yes 273.It net.inet6.ipsec6.inbound_call_ike integer yes 274.It net.inet6.tcp6.43maxseg integer yes 275.It net.inet6.tcp6.conntimeo integer yes 276.It net.inet6.tcp6.do_rfc1323 integer yes 277.It net.inet6.tcp6.keepcount integer yes 278.It net.inet6.tcp6.keepidle integer yes 279.It net.inet6.tcp6.keepinterval integer yes 280.It net.inet6.tcp6.maxpersistidle integer yes 281.It net.inet6.tcp6.mssdflt integer yes 282.It net.inet6.tcp6.pmtu integer yes 283.It net.inet6.tcp6.pmtu_expire integer yes 284.It net.inet6.tcp6.pmtu_probe integer yes 285.It net.inet6.tcp6.recvspace integer yes 286.It net.inet6.tcp6.sendspace integer yes 287.It net.inet6.tcp6.syn_bucket_limit integer yes 288.It net.inet6.tcp6.syn_cache_interval integer yes 289.It net.inet6.tcp6.syn_cache_limit integer yes 290.It net.inet6.udp6.recvspace integer yes 291.It net.inet6.udp6.sendmax integer yes 292.It net.key.acq_exp_int integer yes 293.It net.key.acq_maxtime integer yes 294.It net.key.debug integer yes 295.It net.key.kill_int integer yes 296.It net.key.random_int integer yes 297.It net.key.spi_max_value integer yes 298.It net.key.spi_min_value integer yes 299.It net.key.spi_try integer yes 300.It proc.<pid>.corename string yes 301.It proc.<pid>.rlimit.coredumpsize.hard integer yes 302.It proc.<pid>.rlimit.coredumpsize.soft integer yes 303.It proc.<pid>.rlimit.cputime.hard integer yes 304.It proc.<pid>.rlimit.cputime.soft integer yes 305.It proc.<pid>.rlimit.datasize.hard integer yes 306.It proc.<pid>.rlimit.datasize.soft integer yes 307.It proc.<pid>.rlimit.filesize.hard integer yes 308.It proc.<pid>.rlimit.filesize.soft integer yes 309.It proc.<pid>.rlimit.maxproc.hard integer yes 310.It proc.<pid>.rlimit.maxproc.soft integer yes 311.It proc.<pid>.rlimit.memorylocked.hard integer yes 312.It proc.<pid>.rlimit.memorylocked.soft integer yes 313.It proc.<pid>.rlimit.memoryuse.hard integer yes 314.It proc.<pid>.rlimit.memoryuse.soft integer yes 315.It proc.<pid>.rlimit.stacksize.hard integer yes 316.It proc.<pid>.rlimit.stacksize.soft integer yes 317.It user.bc_base_max integer no 318.It user.bc_dim_max integer no 319.It user.bc_scale_max integer no 320.It user.bc_string_max integer no 321.It user.coll_weights_max integer no 322.It user.cs_path string no 323.It user.expr_nest_max integer no 324.It user.line_max integer no 325.It user.posix2_c_bind integer no 326.It user.posix2_c_dev integer no 327.It user.posix2_char_term integer no 328.It user.posix2_fort_dev integer no 329.It user.posix2_fort_run integer no 330.It user.posix2_localedef integer no 331.It user.posix2_sw_dev integer no 332.It user.posix2_upe integer no 333.It user.posix2_version integer no 334.It user.re_dup_max integer no 335.It vfs.generic.usermount integer yes 336.It vm.loadavg struct no 337.El 338.Sh EXAMPLES 339.Pp 340For example, to retrieve the maximum number of processes allowed 341in the system, one would use the following request: 342.Bd -literal -offset indent -compact 343sysctl kern.maxproc 344.Ed 345.Pp 346To set the maximum number of processes allowed 347in the system to 1000, one would use the following request: 348.Bd -literal -offset indent -compact 349sysctl -w kern.maxproc=1000 350.Ed 351.Pp 352Information about the system clock rate may be obtained with: 353.Bd -literal -offset indent -compact 354sysctl kern.clockrate 355.Ed 356.Pp 357Information about the load average history may be obtained with: 358.Bd -literal -offset indent -compact 359sysctl vm.loadavg 360.Ed 361.Pp 362To view the values of the per-process variables of the current shell, 363the request: 364.Bd -literal -offset indent -compact 365sysctl proc.$$ 366.Ed 367can be used if the shell interpreter replaces $$ with it's pid (this is true 368for most shells). 369.Pp 370To redirect core dumps to the /var/tmp/<username> directory, 371.Bd -literal -offset indent -compact 372sysctl -w proc.$$.corename=/var/tmp/%u/%n.core 373.Ed 374Shall be used. 375.Bd -literal -offset indent -compact 376sysctl -w proc.curproc.corename=/var/tmp/%u/%n.core 377.Ed 378changes the value for the sysctl process itself, and will not have the desired 379effect. 380 381.Sh FILES 382.Bl -tag -width <netinet/icmpXvar.h> -compact 383.It Pa <sys/sysctl.h> 384definitions for top level identifiers, second level kernel and hardware 385identifiers, and user level identifiers 386.It Pa <sys/socket.h> 387definitions for second level network identifiers 388.It Pa <sys/gmon.h> 389definitions for third level profiling identifiers 390.It Pa <vm/vm_param.h> 391definitions for second level virtual memory identifiers 392.It Pa <netinet/in.h> 393definitions for third level Internet identifiers and 394fourth level IP identifiers 395.It Pa <netinet/icmp_var.h> 396definitions for fourth level ICMP identifiers 397.It Pa <netinet/tcp_var.h> 398definitions for fourth level TCP identifiers 399.It Pa <netinet/udp_var.h> 400definitions for fourth level UDP identifiers 401.El 402.Sh SEE ALSO 403.Xr sysctl 3 404.Sh HISTORY 405.Nm sysctl 406first appeared in 407.Bx 4.4 . 408