17abd0fb2Slogwang.\" Copyright (c) 1993 27abd0fb2Slogwang.\" The Regents of the University of California. All rights reserved. 37abd0fb2Slogwang.\" 47abd0fb2Slogwang.\" Redistribution and use in source and binary forms, with or without 57abd0fb2Slogwang.\" modification, are permitted provided that the following conditions 67abd0fb2Slogwang.\" are met: 77abd0fb2Slogwang.\" 1. Redistributions of source code must retain the above copyright 87abd0fb2Slogwang.\" notice, this list of conditions and the following disclaimer. 97abd0fb2Slogwang.\" 2. Redistributions in binary form must reproduce the above copyright 107abd0fb2Slogwang.\" notice, this list of conditions and the following disclaimer in the 117abd0fb2Slogwang.\" documentation and/or other materials provided with the distribution. 12*22ce4affSfengbojiang.\" 3. Neither the name of the University nor the names of its contributors 137abd0fb2Slogwang.\" may be used to endorse or promote products derived from this software 147abd0fb2Slogwang.\" without specific prior written permission. 157abd0fb2Slogwang.\" 167abd0fb2Slogwang.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 177abd0fb2Slogwang.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 187abd0fb2Slogwang.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 197abd0fb2Slogwang.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 207abd0fb2Slogwang.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 217abd0fb2Slogwang.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 227abd0fb2Slogwang.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 237abd0fb2Slogwang.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 247abd0fb2Slogwang.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 257abd0fb2Slogwang.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 267abd0fb2Slogwang.\" SUCH DAMAGE. 277abd0fb2Slogwang.\" 287abd0fb2Slogwang.\" From: @(#)sysctl.8 8.1 (Berkeley) 6/6/93 297abd0fb2Slogwang.\" $FreeBSD$ 307abd0fb2Slogwang.\" 31*22ce4affSfengbojiang.Dd October 30, 2020 327abd0fb2Slogwang.Dt SYSCTL 8 337abd0fb2Slogwang.Os 347abd0fb2Slogwang.Sh NAME 357abd0fb2Slogwang.Nm sysctl 367abd0fb2Slogwang.Nd get or set kernel state 377abd0fb2Slogwang.Sh SYNOPSIS 387abd0fb2Slogwang.Nm 39*22ce4affSfengbojiang.Op Fl bdehiNnoTtqWx 407abd0fb2Slogwang.Op Fl B Ar bufsize 417abd0fb2Slogwang.Op Fl f Ar filename 42*22ce4affSfengbojiang.Ar name Ns Op = Ns Ar value Ns Op , Ns Ar value 437abd0fb2Slogwang.Ar ... 447abd0fb2Slogwang.Nm 45*22ce4affSfengbojiang.Op Fl bdehNnoTtqWx 467abd0fb2Slogwang.Op Fl B Ar bufsize 477abd0fb2Slogwang.Fl a 487abd0fb2Slogwang.Sh DESCRIPTION 497abd0fb2SlogwangThe 507abd0fb2Slogwang.Nm 517abd0fb2Slogwangutility retrieves kernel state and allows processes with appropriate 527abd0fb2Slogwangprivilege to set kernel state. 537abd0fb2SlogwangThe state to be retrieved or set is described using a 547abd0fb2Slogwang.Dq Management Information Base 557abd0fb2Slogwang.Pq Dq MIB 567abd0fb2Slogwangstyle name, described as a dotted set of 577abd0fb2Slogwangcomponents. 587abd0fb2Slogwang.Pp 597abd0fb2SlogwangThe following options are available: 607abd0fb2Slogwang.Bl -tag -width indent 617abd0fb2Slogwang.It Fl A 627abd0fb2SlogwangEquivalent to 637abd0fb2Slogwang.Fl o a 647abd0fb2Slogwang(for compatibility). 657abd0fb2Slogwang.It Fl a 667abd0fb2SlogwangList all the currently available non-opaque values. 677abd0fb2SlogwangThis option is ignored if one or more variable names are specified on 687abd0fb2Slogwangthe command line. 697abd0fb2Slogwang.It Fl b 707abd0fb2SlogwangForce the value of the variable(s) to be output in raw, binary format. 717abd0fb2SlogwangNo names are printed and no terminating newlines are output. 727abd0fb2SlogwangThis is mostly useful with a single variable. 737abd0fb2Slogwang.It Fl B Ar bufsize 747abd0fb2SlogwangSet the buffer size to read from the 757abd0fb2Slogwang.Nm 767abd0fb2Slogwangto 777abd0fb2Slogwang.Ar bufsize . 787abd0fb2SlogwangThis is necessary for a 797abd0fb2Slogwang.Nm 807abd0fb2Slogwangthat has variable length, and the probe value of 0 is a valid length, such as 817abd0fb2Slogwang.Va kern.arandom . 827abd0fb2Slogwang.It Fl d 837abd0fb2SlogwangPrint the description of the variable instead of its value. 847abd0fb2Slogwang.It Fl e 857abd0fb2SlogwangSeparate the name and the value of the variable(s) with 867abd0fb2Slogwang.Ql = . 877abd0fb2SlogwangThis is useful for producing output which can be fed back to the 887abd0fb2Slogwang.Nm 897abd0fb2Slogwangutility. 907abd0fb2SlogwangThis option is ignored if either 917abd0fb2Slogwang.Fl N 927abd0fb2Slogwangor 937abd0fb2Slogwang.Fl n 947abd0fb2Slogwangis specified, or a variable is being set. 957abd0fb2Slogwang.It Fl f Ar filename 967abd0fb2SlogwangSpecify a file which contains a pair of name and value in each line. 977abd0fb2Slogwang.Nm 987abd0fb2Slogwangreads and processes the specified file first and then processes the name 997abd0fb2Slogwangand value pairs in the command line argument. 1007abd0fb2Slogwang.It Fl h 1017abd0fb2SlogwangFormat output for human, rather than machine, readability. 1027abd0fb2Slogwang.It Fl i 1037abd0fb2SlogwangIgnore unknown OIDs. 1047abd0fb2SlogwangThe purpose is to make use of 1057abd0fb2Slogwang.Nm 1067abd0fb2Slogwangfor collecting data from a variety of machines (not all of which 1077abd0fb2Slogwangare necessarily running exactly the same software) easier. 1087abd0fb2Slogwang.It Fl N 1097abd0fb2SlogwangShow only variable names, not their values. 1107abd0fb2SlogwangThis is particularly useful with shells that offer programmable 1117abd0fb2Slogwangcompletion. 1127abd0fb2SlogwangTo enable completion of variable names in 1137abd0fb2Slogwang.Xr zsh 1 Pq Pa ports/shells/zsh , 1147abd0fb2Slogwanguse the following code: 1157abd0fb2Slogwang.Bd -literal -offset indent 1167abd0fb2Slogwanglistsysctls () { set -A reply $(sysctl -AN ${1%.*}) } 1177abd0fb2Slogwangcompctl -K listsysctls sysctl 1187abd0fb2Slogwang.Ed 1197abd0fb2Slogwang.Pp 1207abd0fb2SlogwangTo enable completion of variable names in 1217abd0fb2Slogwang.Xr tcsh 1 , 1227abd0fb2Slogwanguse: 1237abd0fb2Slogwang.Pp 1247abd0fb2Slogwang.Dl "complete sysctl 'n/*/`sysctl -Na`/'" 1257abd0fb2Slogwang.It Fl n 126*22ce4affSfengbojiangDo not show variable names. 1277abd0fb2SlogwangThis option is useful for setting shell variables. 1287abd0fb2SlogwangFor instance, to save the pagesize in variable 1297abd0fb2Slogwang.Va psize , 1307abd0fb2Slogwanguse: 1317abd0fb2Slogwang.Pp 1327abd0fb2Slogwang.Dl "set psize=`sysctl -n hw.pagesize`" 1337abd0fb2Slogwang.It Fl o 1347abd0fb2SlogwangShow opaque variables (which are normally suppressed). 1357abd0fb2SlogwangThe format and length are printed, as well as a hex dump of the first 1367abd0fb2Slogwangsixteen bytes of the value. 1377abd0fb2Slogwang.It Fl q 1387abd0fb2SlogwangSuppress some warnings generated by 1397abd0fb2Slogwang.Nm 1407abd0fb2Slogwangto standard error. 1417abd0fb2Slogwang.It Fl T 1427abd0fb2SlogwangDisplay only variables that are settable via loader (CTLFLAG_TUN). 1437abd0fb2Slogwang.It Fl t 1447abd0fb2SlogwangPrint the type of the variable. 1457abd0fb2Slogwang.It Fl W 1467abd0fb2SlogwangDisplay only writable variables that are not statistical. 1477abd0fb2SlogwangUseful for determining the set of runtime tunable sysctls. 1487abd0fb2Slogwang.It Fl X 1497abd0fb2SlogwangEquivalent to 1507abd0fb2Slogwang.Fl x a 1517abd0fb2Slogwang(for compatibility). 1527abd0fb2Slogwang.It Fl x 1537abd0fb2SlogwangAs 1547abd0fb2Slogwang.Fl o , 1557abd0fb2Slogwangbut prints a hex dump of the entire value instead of just the first 1567abd0fb2Slogwangfew bytes. 1577abd0fb2Slogwang.El 1587abd0fb2Slogwang.Pp 1597abd0fb2SlogwangThe information available from 1607abd0fb2Slogwang.Nm 1617abd0fb2Slogwangconsists of integers, strings, and opaque types. 1627abd0fb2SlogwangThe 1637abd0fb2Slogwang.Nm 1647abd0fb2Slogwangutility 1657abd0fb2Slogwangonly knows about a couple of opaque types, and will resort to hexdumps 1667abd0fb2Slogwangfor the rest. 1677abd0fb2SlogwangThe opaque information is much more useful if retrieved by special 1687abd0fb2Slogwangpurpose programs such as 1697abd0fb2Slogwang.Xr ps 1 , 1707abd0fb2Slogwang.Xr systat 1 , 1717abd0fb2Slogwangand 1727abd0fb2Slogwang.Xr netstat 1 . 1737abd0fb2Slogwang.Pp 1747abd0fb2SlogwangSome of the variables which cannot be modified during normal system 1757abd0fb2Slogwangoperation can be initialized via 1767abd0fb2Slogwang.Xr loader 8 1777abd0fb2Slogwangtunables. 1787abd0fb2SlogwangThis can for example be done by setting them in 1797abd0fb2Slogwang.Xr loader.conf 5 . 1807abd0fb2SlogwangPlease refer to 1817abd0fb2Slogwang.Xr loader.conf 5 1827abd0fb2Slogwangfor more information on which tunables are available and how to set them. 1837abd0fb2Slogwang.Pp 1847abd0fb2SlogwangThe string and integer information is summarized below. 1857abd0fb2SlogwangFor a detailed description of these variable see 1867abd0fb2Slogwang.Xr sysctl 3 . 1877abd0fb2Slogwang.Pp 1887abd0fb2SlogwangThe changeable column indicates whether a process with appropriate 1897abd0fb2Slogwangprivilege can change the value. 1907abd0fb2SlogwangString and integer values can be set using 1917abd0fb2Slogwang.Nm . 1927abd0fb2Slogwang.Bl -column security.bsd.unprivileged_read_msgbuf integerxxx 1937abd0fb2Slogwang.It Sy "Name Type Changeable" 1947abd0fb2Slogwang.It "kern.ostype string no" 1957abd0fb2Slogwang.It "kern.osrelease string no" 1967abd0fb2Slogwang.It "kern.osrevision integer no" 1977abd0fb2Slogwang.It "kern.version string no" 1987abd0fb2Slogwang.It "kern.maxvnodes integer yes" 1997abd0fb2Slogwang.It "kern.maxproc integer no" 2007abd0fb2Slogwang.It "kern.maxprocperuid integer yes" 2017abd0fb2Slogwang.It "kern.maxfiles integer yes" 2027abd0fb2Slogwang.It "kern.maxfilesperproc integer yes" 2037abd0fb2Slogwang.It "kern.argmax integer no" 2047abd0fb2Slogwang.It "kern.securelevel integer raise only" 2057abd0fb2Slogwang.It "kern.hostname string yes" 2067abd0fb2Slogwang.It "kern.hostid integer yes" 2077abd0fb2Slogwang.It "kern.clockrate struct no" 2087abd0fb2Slogwang.It "kern.posix1version integer no" 2097abd0fb2Slogwang.It "kern.ngroups integer no" 2107abd0fb2Slogwang.It "kern.job_control integer no" 2117abd0fb2Slogwang.It "kern.saved_ids integer no" 2127abd0fb2Slogwang.It "kern.boottime struct no" 2137abd0fb2Slogwang.It "kern.domainname string yes" 2147abd0fb2Slogwang.It "kern.filedelay integer yes" 2157abd0fb2Slogwang.It "kern.dirdelay integer yes" 2167abd0fb2Slogwang.It "kern.metadelay integer yes" 217*22ce4affSfengbojiang.It "kern.osreldate integer no" 2187abd0fb2Slogwang.It "kern.bootfile string yes" 2197abd0fb2Slogwang.It "kern.corefile string yes" 2207abd0fb2Slogwang.It "kern.logsigexit integer yes" 2217abd0fb2Slogwang.It "security.bsd.suser_enabled integer yes" 2227abd0fb2Slogwang.It "security.bsd.see_other_uids integer yes" 2237abd0fb2Slogwang.It "security.bsd.unprivileged_proc_debug integer yes" 2247abd0fb2Slogwang.It "security.bsd.unprivileged_read_msgbuf integer yes" 2257abd0fb2Slogwang.It "vm.loadavg struct no" 2267abd0fb2Slogwang.It "hw.machine string no" 2277abd0fb2Slogwang.It "hw.model string no" 2287abd0fb2Slogwang.It "hw.ncpu integer no" 2297abd0fb2Slogwang.It "hw.byteorder integer no" 2307abd0fb2Slogwang.It "hw.physmem integer no" 2317abd0fb2Slogwang.It "hw.usermem integer no" 2327abd0fb2Slogwang.It "hw.pagesize integer no" 2337abd0fb2Slogwang.It "hw.floatingpoint integer no" 2347abd0fb2Slogwang.It "hw.machine_arch string no" 2357abd0fb2Slogwang.It "hw.realmem integer no" 2367abd0fb2Slogwang.It "machdep.adjkerntz integer yes" 2377abd0fb2Slogwang.It "machdep.disable_rtc_set integer yes" 2387abd0fb2Slogwang.It "machdep.guessed_bootdev string no" 2397abd0fb2Slogwang.It "user.cs_path string no" 2407abd0fb2Slogwang.It "user.bc_base_max integer no" 2417abd0fb2Slogwang.It "user.bc_dim_max integer no" 2427abd0fb2Slogwang.It "user.bc_scale_max integer no" 2437abd0fb2Slogwang.It "user.bc_string_max integer no" 2447abd0fb2Slogwang.It "user.coll_weights_max integer no" 2457abd0fb2Slogwang.It "user.expr_nest_max integer no" 2467abd0fb2Slogwang.It "user.line_max integer no" 2477abd0fb2Slogwang.It "user.re_dup_max integer no" 2487abd0fb2Slogwang.It "user.posix2_version integer no" 2497abd0fb2Slogwang.It "user.posix2_c_bind integer no" 2507abd0fb2Slogwang.It "user.posix2_c_dev integer no" 2517abd0fb2Slogwang.It "user.posix2_char_term integer no" 2527abd0fb2Slogwang.It "user.posix2_fort_dev integer no" 2537abd0fb2Slogwang.It "user.posix2_fort_run integer no" 2547abd0fb2Slogwang.It "user.posix2_localedef integer no" 2557abd0fb2Slogwang.It "user.posix2_sw_dev integer no" 2567abd0fb2Slogwang.It "user.posix2_upe integer no" 2577abd0fb2Slogwang.It "user.stream_max integer no" 2587abd0fb2Slogwang.It "user.tzname_max integer no" 259*22ce4affSfengbojiang.It "user.localbase string no" 2607abd0fb2Slogwang.El 2617abd0fb2Slogwang.Sh FILES 2627abd0fb2Slogwang.Bl -tag -width ".In netinet/icmp_var.h" -compact 2637abd0fb2Slogwang.It In sys/sysctl.h 2647abd0fb2Slogwangdefinitions for top level identifiers, second level kernel and hardware 2657abd0fb2Slogwangidentifiers, and user level identifiers 2667abd0fb2Slogwang.It In sys/socket.h 2677abd0fb2Slogwangdefinitions for second level network identifiers 2687abd0fb2Slogwang.It In sys/gmon.h 2697abd0fb2Slogwangdefinitions for third level profiling identifiers 2707abd0fb2Slogwang.It In vm/vm_param.h 2717abd0fb2Slogwangdefinitions for second level virtual memory identifiers 2727abd0fb2Slogwang.It In netinet/in.h 2737abd0fb2Slogwangdefinitions for third level Internet identifiers and 2747abd0fb2Slogwangfourth level IP identifiers 2757abd0fb2Slogwang.It In netinet/icmp_var.h 2767abd0fb2Slogwangdefinitions for fourth level ICMP identifiers 2777abd0fb2Slogwang.It In netinet/udp_var.h 2787abd0fb2Slogwangdefinitions for fourth level UDP identifiers 2797abd0fb2Slogwang.El 280*22ce4affSfengbojiang.Sh EXIT STATUS 281*22ce4affSfengbojiang.Ex -std 2827abd0fb2Slogwang.Sh EXAMPLES 2837abd0fb2SlogwangFor example, to retrieve the maximum number of processes allowed 2847abd0fb2Slogwangin the system, one would use the following request: 2857abd0fb2Slogwang.Pp 2867abd0fb2Slogwang.Dl "sysctl kern.maxproc" 2877abd0fb2Slogwang.Pp 2887abd0fb2SlogwangTo set the maximum number of processes allowed 2897abd0fb2Slogwangper uid to 1000, one would use the following request: 2907abd0fb2Slogwang.Pp 2917abd0fb2Slogwang.Dl "sysctl kern.maxprocperuid=1000" 2927abd0fb2Slogwang.Pp 2937abd0fb2SlogwangInformation about the system clock rate may be obtained with: 2947abd0fb2Slogwang.Pp 2957abd0fb2Slogwang.Dl "sysctl kern.clockrate" 2967abd0fb2Slogwang.Pp 2977abd0fb2SlogwangInformation about the load average history may be obtained with: 2987abd0fb2Slogwang.Pp 2997abd0fb2Slogwang.Dl "sysctl vm.loadavg" 3007abd0fb2Slogwang.Pp 3017abd0fb2SlogwangMore variables than these exist, and the best and likely only place 3027abd0fb2Slogwangto search for their deeper meaning is undoubtedly the source where 3037abd0fb2Slogwangthey are defined. 3047abd0fb2Slogwang.Sh COMPATIBILITY 3057abd0fb2SlogwangThe 3067abd0fb2Slogwang.Fl w 3077abd0fb2Slogwangoption has been deprecated and is silently ignored. 3087abd0fb2Slogwang.Sh SEE ALSO 3097abd0fb2Slogwang.Xr sysctl 3 , 3107abd0fb2Slogwang.Xr loader.conf 5 , 3117abd0fb2Slogwang.Xr sysctl.conf 5 , 3127abd0fb2Slogwang.Xr loader 8 3137abd0fb2Slogwang.Sh HISTORY 3147abd0fb2SlogwangA 3157abd0fb2Slogwang.Nm 3167abd0fb2Slogwangutility first appeared in 3177abd0fb2Slogwang.Bx 4.4 . 3187abd0fb2Slogwang.Pp 3197abd0fb2SlogwangIn 3207abd0fb2Slogwang.Fx 2.2 , 3217abd0fb2Slogwang.Nm 3227abd0fb2Slogwangwas significantly remodeled. 3237abd0fb2Slogwang.Sh BUGS 3247abd0fb2SlogwangThe 3257abd0fb2Slogwang.Nm 3267abd0fb2Slogwangutility presently exploits an undocumented interface to the kernel 3277abd0fb2Slogwangsysctl facility to traverse the sysctl tree and to retrieve format 3287abd0fb2Slogwangand name information. 3297abd0fb2SlogwangThis correct interface is being thought about for the time being. 330