xref: /freebsd/sbin/sysctl/sysctl.8 (revision 0fddbf874719b9bd50cf66ac26d1140bb3f2be69)
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.\" $FreeBSD$
34.\"
35.Dd May 28, 2001
36.Dt SYSCTL 8
37.Os
38.Sh NAME
39.Nm sysctl
40.Nd get or set kernel state
41.Sh SYNOPSIS
42.Nm
43.Op Fl bNnox
44.Ar name Ns Op = Ns Ar value
45.Ar ...
46.Nm
47.Op Fl bNnox
48.Fl a
49.Sh DESCRIPTION
50The
51.Nm
52utility retrieves kernel state and allows processes with appropriate
53privilege to set kernel state.
54The state to be retrieved or set is described using a
55.Dq Management Information Base
56.Pq Dq MIB
57style name, described as a dotted set of
58components.
59.Pp
60The following options are available:
61.Bl -tag -width indent
62.It Fl A
63Equivalent to
64.Fl o a
65(for compatibility).
66.It Fl a
67List all the currently available non-opaque values.
68This option is ignored if one or more variable names are specified on
69the command line.
70.It Fl b
71Force the value of the variable(s) to be output in raw, binary format.
72No names are printed and no terminating newlines are output.
73This is mostly useful with a single variable.
74.It Fl N
75Show only variable names, not their values.
76This is particularly useful with shells that offer programmable
77completion.
78To enable completion of variable names in
79.Nm zsh ,
80use the following code:
81.Bd -literal -offset indent
82listsysctls () { set -A reply $(sysctl -AN ${1%.*}) }
83compctl -K listsysctls sysctl
84.Ed
85.It Fl n
86Show only variable values, not their names.
87This option is useful for setting shell variables.
88For instance, to save the pagesize in variable
89.Va psize ,
90use:
91.Pp
92.Dl "set psize=`sysctl -n hw.pagesize`"
93.It Fl o
94Show opaque variables (which are normally suppressed).
95The format and length are printed, as well as a hex dump of the first
96sixteen bytes of the value.
97.It Fl X
98Equivalent to
99.Fl x a
100(for compatibility).
101.It Fl x
102As
103.Fl o ,
104but prints a hex dump of the entire value instead of just the first
105few bytes.
106.El
107.Pp
108The information available from
109.Nm
110consists of integers, strings, and opaques.
111.Nm Sysctl
112only knows about a couple of opaque types, and will resort to hexdumps
113for the rest.
114The opaque information is much more useful if retrieved by special
115purpose programs such as
116.Nm ps , systat ,
117and
118.Nm netstat .
119.Pp
120The string and integer information is summarized below.
121For a detailed description of these variable see
122.Xr sysctl 3 .
123.Pp
124The changeable column indicates whether a process with appropriate
125privilege can change the value.
126.Bl -column net.inet.ip.forwardingxxxxxx integerxxx
127.It Sy "Name	Type	Changeable
128.It "kern.ostype	string	no
129.It "kern.osrelease	string	no
130.It "kern.osrevision	integer	no
131.It "kern.version	string	no
132.It "kern.maxvnodes	integer	yes
133.It "kern.maxproc	integer	no
134.It "kern.maxprocperuid	integer	yes
135.It "kern.maxfiles	integer	yes
136.It "kern.maxfilesperproc	integer	yes
137.It "kern.argmax	integer	no
138.It "kern.suser_permitted	integer	yes
139.It "kern.securelevel	integer	raise only
140.It "kern.hostname	string	yes
141.It "kern.hostid	integer	yes
142.It "kern.clockrate	struct	no
143.It "kern.posix1version	integer	no
144.It "kern.ngroups	integer	no
145.It "kern.job_control	integer	no
146.It "kern.saved_ids	integer	no
147.It "kern.boottime	struct	no
148.It "kern.domainname	string	yes
149.It "kern.filedelay	integer	yes
150.It "kern.dirdelay	integer	yes
151.It "kern.metadelay	integer	yes
152.It "kern.osreldate	string	no
153.It "kern.bootfile	string	yes
154.It "kern.corefile	string	yes
155.It "kern.logsigexit	integer	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 "hw.machine_arch	string	no
166.It "machdep.console_device	dev_t	no
167.It "machdep.adjkerntz	integer	yes
168.It "machdep.disable_rtc_set	integer	yes
169.It "user.cs_path	string	no
170.It "user.bc_base_max	integer	no
171.It "user.bc_dim_max	integer	no
172.It "user.bc_scale_max	integer	no
173.It "user.bc_string_max	integer	no
174.It "user.coll_weights_max	integer	no
175.It "user.expr_nest_max	integer	no
176.It "user.line_max	integer	no
177.It "user.re_dup_max	integer	no
178.It "user.posix2_version	integer	no
179.It "user.posix2_c_bind	integer	no
180.It "user.posix2_c_dev	integer	no
181.It "user.posix2_char_term	integer	no
182.It "user.posix2_fort_dev	integer	no
183.It "user.posix2_fort_run	integer	no
184.It "user.posix2_localedef	integer	no
185.It "user.posix2_sw_dev	integer	no
186.It "user.posix2_upe	integer	no
187.It "user.stream_max	integer	no
188.It "user.tzname_max	integer	no
189.El
190.Sh EXAMPLES
191For example, to retrieve the maximum number of processes allowed
192in the system, one would use the following request:
193.Pp
194.Dl "sysctl kern.maxproc"
195.Pp
196To set the maximum number of processes allowed
197per uid to 1000, one would use the following request:
198.Pp
199.Dl "sysctl kern.maxprocperuid=1000"
200.Pp
201Information about the system clock rate may be obtained with:
202.Pp
203.Dl "sysctl kern.clockrate"
204.Pp
205Information about the load average history may be obtained with:
206.Pp
207.Dl "sysctl vm.loadavg"
208.Pp
209More variables than these exist, and the best and likely only place
210to search for their deeper meaning is undoubtedly the source where
211they are defined.
212.Sh FILES
213.Bl -tag -width ".Aq Pa netinet/icmp_var.h" -compact
214.It Aq Pa sys/sysctl.h
215definitions for top level identifiers, second level kernel and hardware
216identifiers, and user level identifiers
217.It Aq Pa sys/socket.h
218definitions for second level network identifiers
219.It Aq Pa sys/gmon.h
220definitions for third level profiling identifiers
221.It Aq Pa vm/vm_param.h
222definitions for second level virtual memory identifiers
223.It Aq Pa netinet/in.h
224definitions for third level Internet identifiers and
225fourth level IP identifiers
226.It Aq Pa netinet/icmp_var.h
227definitions for fourth level ICMP identifiers
228.It Aq Pa netinet/udp_var.h
229definitions for fourth level UDP identifiers
230.El
231.Sh COMPATIBILITY
232The
233.Fl w
234option has been deprecated and is silently ignored.
235.Sh SEE ALSO
236.Xr sysctl 3 ,
237.Xr sysctl.conf 5
238.Sh BUGS
239.Nm Sysctl
240presently exploits an undocumented interface to the kernel
241sysctl facility to traverse the sysctl tree and to retrieve format
242and name information.
243This correct interface is being thought about for the time being.
244.Sh HISTORY
245.Nm Sysctl
246first appeared in
247.Bx 4.4 .
248.Pp
249In
250.Fx 2.2 ,
251.Nm
252was significantly remodeled.
253