1.\" $NetBSD: sysctl.8,v 1.93 2003/04/19 21:55:48 christos 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 February 2, 2003 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.Op Fl q 49.Fl w 50.Ar name Ns Li = Ns Ar value ... 51.Nm sysctl 52.Op Fl n 53.Fl a 54.Nm sysctl 55.Op Fl n 56.Fl A 57.Nm sysctl 58.Op Fl n 59.Op Fl q 60.Fl f 61.Ar file 62.Sh DESCRIPTION 63The 64.Nm sysctl 65utility retrieves kernel state and allows processes with 66appropriate privilege to set kernel state. 67The state to be retrieved or set is described using a 68``Management Information Base'' (``MIB'') style name, 69described as a dotted set of components. 70The 71.Fl a 72flag can be used to list all the currently available string or integer values. 73The 74.Fl A 75flag will list all the known MIB names including tables. 76Those with string or integer values will be printed as with the 77.Fl a 78flag; for the table values, 79the name of the utility to retrieve them is given. 80.Pp 81The 82.Fl n 83flag specifies that the printing of the field name should be 84suppressed and that only its value should be output. 85This flag is useful for setting shell variables. 86For example, to save the pagesize in variable psize, use: 87.Bd -literal -offset indent -compact 88set psize=`sysctl -n hw.pagesize` 89.Ed 90.Pp 91If just a MIB style name is given, 92the corresponding value is retrieved. 93If a value is to be set, the 94.Fl w 95flag must be specified and the MIB name followed 96by an equal sign and the new value to be used. 97.Pp 98The 99.Fl f 100flag specifies the name of a file to read and process. 101Blank lines and comments (beginning with 102.Ql # ) 103are ignored. 104Line continuations with 105.Ql \e 106are permitted. 107Remaining lines are processed similarly to 108command line arguments of the form 109.Ar name 110or 111.Ar name Ns Li = Ns Ar value . 112The 113.Fl w 114flag is implied by 115.Fl f . 116.Pp 117The 118.Fl q 119flag may be used with 120.Fl f 121and 122.Fl w 123to indicate that nothing should be printed for writes unless an error is 124detected. 125.Pp 126The 127.Ql proc 128top-level MIB has a special semantic: it represent per-process values 129and as such may differ from one process to another. 130The second-level name is the pid of the process (in decimal form), 131or the special word 132.Ql curproc . 133For variables below 134.Ql proc.\*[Lt]pid\*[Gt].rlimit , 135the integer value may be replaced 136with the string 137.Ql unlimited 138if it matches the magic value used to disable 139a limit. 140.Pp 141The information available from 142.Nm sysctl 143consists of integers, strings, and tables. 144The tabular information can only be retrieved by special 145purpose programs such as 146.Nm ps , 147.Nm systat , 148and 149.Nm netstat . 150The string and integer information is summarized below. 151For a detailed description of these variable see 152.Xr sysctl 3 . 153The changeable column indicates whether a process with appropriate 154privilege can change the value. 155.Bl -column proc.xpidx.rlimit.coredumpsize.hardxxxxxx integerxxx 156.It Sy Name Type Changeable 157.It ddb.fromconsole integer yes 158.It ddb.lines integer yes 159.It ddb.maxoff integer yes 160.It ddb.maxwidth integer yes 161.It ddb.onpanic integer yes 162.It ddb.radix integer yes 163.It ddb.tabstops integer yes 164.It hw.alignbytes integer no 165.It hw.byteorder integer no 166.It hw.disknames string no 167.It hw.diskstats struct no 168.It hw.machine string no 169.It hw.machine_arch string no 170.It hw.model string no 171.It hw.ncpu integer no 172.It hw.pagesize integer no 173.It hw.physmem integer no 174.It hw.physmem64 quad no 175.It hw.usermem integer no 176.It hw.usermem64 quad no 177.It hw.cnmagic string yes 178.It kern.argmax integer no 179.It kern.autonicetime integer yes 180.It kern.autoniceval integer yes 181.It kern.boottime struct no 182.It kern.ccpu integer no 183.It kern.chown_restricted integer no 184.It kern.clockrate struct no 185.It kern.consdev integer no 186.It kern.cp_time struct no 187.It kern.defcorename string yes 188.It kern.domainname string yes 189.It kern.forkfsleep integer yes 190.It kern.fscale integer no 191.It kern.fsync integer no 192.It kern.hostid integer yes 193.It kern.hostname string yes 194.It kern.iov_max integer no 195.It kern.job_control integer no 196.It kern.labeloffset integer no 197.It kern.labelsector integer no 198.It kern.link_max integer no 199.It kern.login_name_max integer no 200.It kern.logsigexit integer yes 201.It kern.max_canon integer no 202.It kern.max_input integer no 203.It kern.maxfiles integer yes 204.It kern.maxpartitions integer no 205.It kern.maxproc integer yes 206.It kern.maxptys integer yes, special 207.It kern.maxvnodes integer raise only 208.It kern.mapped_files integer no 209.It kern.maxphys integer no 210.It kern.memlock integer no 211.It kern.memlock_range integer no 212.It kern.memory_protection integer no 213.It kern.mbuf.mblowat integer yes 214.It kern.mbuf.mcllowat integer yes 215.It kern.mbuf.mclsize integer no 216.It kern.mbuf.msize integer no 217.It kern.mbuf.nmbclusters integer raise only 218.It kern.monotonic_clock integer no 219.It kern.msgbuf struct no 220.It kern.msgbufsize integer no 221.It kern.name_max integer no 222.It kern.ngroups integer no 223.It kern.no_trunc integer no 224.It kern.ntptime struct no 225.It kern.osrelease string no 226.It kern.osrevision integer no 227.It kern.ostype string no 228.It kern.path_max integer no 229.It kern.pipe.maxkvasz integer yes 230.It kern.pipe.maxloankvasz integer yes 231.It kern.pipe.maxbigpipes integer yes 232.It kern.pipe.nbigpipes integer no 233.It kern.pipe.kvasize integer no 234.It kern.posix1version integer no 235.It kern.posix_barriers integer no 236.It kern.posix_reader_writer_locks integer no 237.It kern.posix_semaphores integer no 238.It kern.posix_spin_locks integer no 239.It kern.posix_timers integer no 240.It kern.posix_threads integer no 241.It kern.proc2 struct no 242.It kern.proc_args string yes 243.It kern.rawpartition integer no 244.It kern.rtc_offset integer no 245.It kern.saved_ids integer no 246.It kern.sbmax integer yes 247.It kern.securelevel integer raise only 248.It kern.synchronized_io integer no 249.It kern.sysvipc_info struct no 250.It kern.sysvmsg integer no 251.It kern.sysvsem integer no 252.It kern.sysvshm integer no 253.It kern.timex struct no 254.It kern.tkstat.nin quad no 255.It kern.tkstat.nout quad no 256.It kern.tkstat.cancc quad no 257.It kern.tkstat.rawcc quad no 258.It kern.urnd integer no 259.It kern.vdisable integer no 260.It kern.version string no 261.It machdep.console_device dev_t no 262.It net.inet.icmp.maskrepl integer yes 263.It net.inet.icmp.errppslimit integer yes 264.It net.inet.icmp.rediraccept integer yes 265.It net.inet.icmp.redirtimeout integer yes 266.It net.inet.ip.allowsrcrt integer yes 267.It net.inet.ip.anonportmax integer yes 268.It net.inet.ip.anonportmin integer yes 269.It net.inet.ip.checkinterface integer yes 270.It net.inet.ip.directed-broadcast integer yes 271.It net.inet.ip.forwarding integer yes 272.It net.inet.ip.forwsrcrt integer yes 273.It net.inet.ip.maxfragpacket integer yes 274.It net.inet.ip.lowportmax integer yes 275.It net.inet.ip.lowportmin integer yes 276.It net.inet.ip.mtudisc integer yes 277.It net.inet.ip.mtudisctimeout integer yes 278.It net.inet.ip.redirect integer yes 279.It net.inet.ip.subnetsarelocal integer yes 280.It net.inet.ip.ttl integer yes 281.It net.inet.ipsec.ah_cleartos integer yes 282.It net.inet.ipsec.ah_net_deflev integer yes 283.It net.inet.ipsec.ah_offsetmask integer yes 284.It net.inet.ipsec.ah_trans_deflev integer yes 285.It net.inet.ipsec.def_policy integer yes 286.It net.inet.ipsec.dfbit integer yes 287.It net.inet.ipsec.ecn integer yes 288.It net.inet.ipsec.esp_net_deflev integer yes 289.It net.inet.ipsec.esp_trans_deflev integer yes 290.It net.inet.ipsec.inbound_call_ike integer yes 291.It net.inet.tcp.ack_on_push integer yes 292.It net.inet.tcp.compat_42 integer yes 293.It net.inet.tcp.cwm integer yes 294.It net.inet.tcp.cwm_burstsize integer yes 295.It net.inet.tcp.init_win integer yes 296.It net.inet.tcp.init_win_local integer yes 297.It net.inet.tcp.keepcnt integer yes 298.It net.inet.tcp.keepidle integer yes 299.It net.inet.tcp.keepintvl integer yes 300.It net.inet.tcp.log_refused integer yes 301.It net.inet.tcp.mss_ifmtu integer yes 302.It net.inet.tcp.mssdflt integer yes 303.It net.inet.tcp.recvspace integer yes 304.It net.inet.tcp.rfc1323 integer yes 305.It net.inet.tcp.rstppslimit integer yes 306.It net.inet.tcp.sack integer yes 307.It net.inet.tcp.sendspace integer yes 308.It net.inet.tcp.slowhz integer no 309.It net.inet.tcp.syn_bucket_limit integer yes 310.It net.inet.tcp.syn_cache_interval integer yes 311.It net.inet.tcp.syn_cache_limit integer yes 312.It net.inet.tcp.timestamps integer yes 313.It net.inet.tcp.win_scale integer yes 314.It net.inet.tcp.ident struct no 315.It net.inet.udp.checksum integer yes 316.It net.inet.udp.recvspace integer yes 317.It net.inet.udp.sendspace integer yes 318.It net.inet6.icmp6.errppslimit integer yes 319.It net.inet6.icmp6.mtudisc_hiwat integer yes 320.It net.inet6.icmp6.mtudisc_lowat integer yes 321.It net.inet6.icmp6.nd6_debug integer yes 322.It net.inet6.icmp6.nd6_delay integer yes 323.It net.inet6.icmp6.nd6_maxnudhint integer yes 324.It net.inet6.icmp6.nd6_mmaxtries integer yes 325.It net.inet6.icmp6.nd6_prune integer yes 326.It net.inet6.icmp6.nd6_umaxtries integer yes 327.It net.inet6.icmp6.nd6_useloopback integer yes 328.It net.inet6.icmp6.nodeinfo integer yes 329.It net.inet6.icmp6.rediraccept integer yes 330.It net.inet6.icmp6.redirtimeout integer yes 331.It net.inet6.ip6.accept_rtadv integer yes 332.It net.inet6.ip6.anonportmax integer yes 333.It net.inet6.ip6.anonportmin integer yes 334.It net.inet6.ip6.auto_flowlabel integer yes 335.It net.inet6.ip6.v6only integer yes 336.It net.inet6.ip6.dad_count integer yes 337.It net.inet6.ip6.defmcasthlim integer yes 338.It net.inet6.ip6.forwarding integer yes 339.It net.inet6.ip6.gif_hlim integer yes 340.It net.inet6.ip6.hdrnestlimit integer yes 341.It net.inet6.ip6.hlim integer yes 342.It net.inet6.ip6.kame_version string no 343.It net.inet6.ip6.keepfaith integer yes 344.It net.inet6.ip6.log_interval integer yes 345.It net.inet6.ip6.lowportmax integer yes 346.It net.inet6.ip6.lowportmin integer yes 347.It net.inet6.ip6.maxfragpackets integer yes 348.It net.inet6.ip6.maxfrags integer yes 349.It net.inet6.ip6.redirect integer yes 350.It net.inet6.ip6.rr_prune integer yes 351.It net.inet6.ip6.use_deprecated integer yes 352.It net.inet6.ipsec6.ah_net_deflev integer yes 353.It net.inet6.ipsec6.ah_trans_deflev integer yes 354.It net.inet6.ipsec6.def_policy integer yes 355.It net.inet6.ipsec6.ecn integer yes 356.It net.inet6.ipsec6.esp_net_deflev integer yes 357.It net.inet6.ipsec6.esp_trans_deflev integer yes 358.It net.inet6.ipsec6.inbound_call_ike integer yes 359.It net.inet6.udp6.recvspace integer yes 360.It net.inet6.udp6.sendspace integer yes 361.It net.key.acq_exp_int integer yes 362.It net.key.acq_maxtime integer yes 363.It net.key.ah_keymin integer yes 364.It net.key.debug integer yes 365.It net.key.esp_auth integer yes 366.It net.key.esp_keymin integer yes 367.It net.key.kill_int integer yes 368.It net.key.random_int integer yes 369.It net.key.spi_max_value integer yes 370.It net.key.spi_min_value integer yes 371.It net.key.spi_try integer yes 372.It proc.\*[Lt]pid\*[Gt].corename string yes 373.It proc.\*[Lt]pid\*[Gt].rlimit.coredumpsize.hard integer yes 374.It proc.\*[Lt]pid\*[Gt].rlimit.coredumpsize.soft integer yes 375.It proc.\*[Lt]pid\*[Gt].rlimit.cputime.hard integer yes 376.It proc.\*[Lt]pid\*[Gt].rlimit.cputime.soft integer yes 377.It proc.\*[Lt]pid\*[Gt].rlimit.datasize.hard integer yes 378.It proc.\*[Lt]pid\*[Gt].rlimit.datasize.soft integer yes 379.It proc.\*[Lt]pid\*[Gt].rlimit.filesize.hard integer yes 380.It proc.\*[Lt]pid\*[Gt].rlimit.filesize.soft integer yes 381.It proc.\*[Lt]pid\*[Gt].rlimit.maxproc.hard integer yes 382.It proc.\*[Lt]pid\*[Gt].rlimit.maxproc.soft integer yes 383.It proc.\*[Lt]pid\*[Gt].rlimit.memorylocked.hard integer yes 384.It proc.\*[Lt]pid\*[Gt].rlimit.memorylocked.soft integer yes 385.It proc.\*[Lt]pid\*[Gt].rlimit.memoryuse.hard integer yes 386.It proc.\*[Lt]pid\*[Gt].rlimit.memoryuse.soft integer yes 387.It proc.\*[Lt]pid\*[Gt].rlimit.stacksize.hard integer yes 388.It proc.\*[Lt]pid\*[Gt].rlimit.stacksize.soft integer yes 389.It proc.\*[Lt]pid\*[Gt].stopexec int yes 390.It proc.\*[Lt]pid\*[Gt].stopfork int yes 391.It user.bc_base_max integer no 392.It user.bc_dim_max integer no 393.It user.bc_scale_max integer no 394.It user.bc_string_max integer no 395.It user.coll_weights_max integer no 396.It user.cs_path string no 397.It user.expr_nest_max integer no 398.It user.line_max integer no 399.It user.posix2_c_bind integer no 400.It user.posix2_c_dev integer no 401.It user.posix2_char_term integer no 402.It user.posix2_fort_dev integer no 403.It user.posix2_fort_run integer no 404.It user.posix2_localedef integer no 405.It user.posix2_sw_dev integer no 406.It user.posix2_upe integer no 407.It user.posix2_version integer no 408.It user.re_dup_max integer no 409.It vendor.\*[Lt]vendor\*[Gt].* ? vendor specific 410.It vfs.generic.usermount integer yes 411.It vfs.nfs.iothreads integer yes 412.It vm.anonmax integer yes 413.It vm.anonmin integer yes 414.It vm.execmax integer yes 415.It vm.execmin integer yes 416.It vm.filemax integer yes 417.It vm.filemin integer yes 418.It vm.loadavg struct no 419.It vm.nkmempages integer no 420.It vm.uvmexp struct no 421.It vm.uvmexp2 struct no 422.It vm.vmmeter struct no 423.El 424.Pp 425Entries found under 426.Dq vendor.\*[Lt]vendor\*[Gt] 427are left to be specified (and used) by vendors 428using the 429.Nx 430operating system in their products. 431Values and structure are vendor-defined, and no registry 432exists right now. 433.Sh FILES 434.Bl -tag -width xnetinet6/udp6Xvar.hx -compact 435.It Aq Pa sys/sysctl.h 436definitions for top level identifiers, second level kernel and hardware 437identifiers, and user level identifiers 438.It Aq Pa sys/socket.h 439definitions for second level network identifiers 440.It Aq Pa sys/gmon.h 441definitions for third level profiling identifiers 442.It Aq Pa uvm/uvm_param.h 443definitions for second level virtual memory identifiers 444.It Aq Pa netinet/in.h 445definitions for third level IPv4/v6 identifiers and 446fourth level IPv4/v6 identifiers 447.It Aq Pa netinet/icmp_var.h 448definitions for fourth level ICMP identifiers 449.It Aq Pa netinet/icmp6.h 450definitions for fourth level ICMPv6 identifiers 451.It Aq Pa netinet/tcp_var.h 452definitions for fourth level TCP identifiers 453.It Aq Pa netinet/udp_var.h 454definitions for fourth level UDP identifiers 455.It Aq Pa netinet6/udp6_var.h 456definitions for fourth level IPv6 UDP identifiers 457.It Aq Pa netinet6/ipsec.h 458definitions for fourth level IPsec identifiers 459.It Aq Pa netkey/key_var.h 460definitions for third level PF_KEY identifiers 461.El 462.Sh EXAMPLES 463For example, to retrieve the maximum number of processes allowed 464in the system, one would use the following request: 465.Bd -literal -offset indent -compact 466sysctl kern.maxproc 467.Ed 468.Pp 469To set the maximum number of processes allowed 470in the system to 1000, one would use the following request: 471.Bd -literal -offset indent -compact 472sysctl -w kern.maxproc=1000 473.Ed 474.Pp 475Information about the system clock rate may be obtained with: 476.Bd -literal -offset indent -compact 477sysctl kern.clockrate 478.Ed 479.Pp 480Information about the load average history may be obtained with: 481.Bd -literal -offset indent -compact 482sysctl vm.loadavg 483.Ed 484.Pp 485To view the values of the per-process variables of the current shell, 486the request: 487.Bd -literal -offset indent -compact 488sysctl proc.$$ 489.Ed 490can be used if the shell interpreter replaces $$ with its pid (this is true 491for most shells). 492.Pp 493To redirect core dumps to the /var/tmp/\*[Lt]username\*[Gt] directory, 494.Bd -literal -offset indent -compact 495sysctl -w proc.$$.corename=/var/tmp/%u/%n.core 496.Ed 497Shall be used. 498.Bd -literal -offset indent -compact 499sysctl -w proc.curproc.corename=/var/tmp/%u/%n.core 500.Ed 501changes the value for the sysctl process itself, and will not have the desired 502effect. 503.Sh SEE ALSO 504.Xr sysctl 3 505.Sh HISTORY 506.Nm sysctl 507first appeared in 508.Bx 4.4 . 509