xref: /freebsd/sbin/sysctl/sysctl.8 (revision 3193579b66fd7067f898dbc54bdea81a0e6f9bd0)
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 March 10, 2002
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 bdehNnox
44.Ar name Ns Op = Ns Ar value
45.Ar ...
46.Nm
47.Op Fl bdehNnox
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 d
75Print the description of the variable instead of its value.
76.It Fl e
77Separate the name and the value of the variable(s) with
78.Ql = .
79This is useful for producing output which can be fed back to the
80.Nm
81utility.
82This option is ignored if either
83.Fl N
84or
85.Fl n
86is specified, or a variable is being set.
87.It Fl h
88Format output for human, rather than machine, readability.
89.It Fl N
90Show only variable names, not their values.
91This is particularly useful with shells that offer programmable
92completion.
93To enable completion of variable names in
94.Xr zsh 1 ,
95use the following code:
96.Bd -literal -offset indent
97listsysctls () { set -A reply $(sysctl -AN ${1%.*}) }
98compctl -K listsysctls sysctl
99.Ed
100.It Fl n
101Show only variable values, not their names.
102This option is useful for setting shell variables.
103For instance, to save the pagesize in variable
104.Va psize ,
105use:
106.Pp
107.Dl "set psize=`sysctl -n hw.pagesize`"
108.It Fl o
109Show opaque variables (which are normally suppressed).
110The format and length are printed, as well as a hex dump of the first
111sixteen bytes of the value.
112.It Fl X
113Equivalent to
114.Fl x a
115(for compatibility).
116.It Fl x
117As
118.Fl o ,
119but prints a hex dump of the entire value instead of just the first
120few bytes.
121.El
122.Pp
123The information available from
124.Nm
125consists of integers, strings, devices
126.Pq Vt dev_t ,
127and opaque types.
128The
129.Nm
130utility
131only knows about a couple of opaque types, and will resort to hexdumps
132for the rest.
133The opaque information is much more useful if retrieved by special
134purpose programs such as
135.Xr ps 1 ,
136.Xr systat 1 ,
137and
138.Xr netstat 1 .
139.Pp
140Some of the variables which cannot be modified during normal system
141operation can be initialized via
142.Xr loader 8
143tunables.
144This can for example be done by setting them in
145.Xr loader.conf 5 .
146Please refer to
147.Xr loader.conf 5
148for more information on which tunables are available and how to set them.
149.Pp
150The string and integer information is summarized below.
151For a detailed description of these variable see
152.Xr sysctl 3 .
153.Pp
154The changeable column indicates whether a process with appropriate
155privilege can change the value.
156String, integer, and devices values can be set using
157.Nm .
158For device values,
159.Ar value
160can be specified as a character device special file name.
161Special values
162.Cm off
163and
164.Cm none
165denote
166.Dq no device .
167.Bl -column security.bsd.unprivileged_read_msgbuf integerxxx
168.It Sy "Name	Type	Changeable
169.It "kern.ostype	string	no
170.It "kern.osrelease	string	no
171.It "kern.osrevision	integer	no
172.It "kern.version	string	no
173.It "kern.maxvnodes	integer	yes
174.It "kern.maxproc	integer	no
175.It "kern.maxprocperuid	integer	yes
176.It "kern.maxfiles	integer	yes
177.It "kern.maxfilesperproc	integer	yes
178.It "kern.argmax	integer	no
179.It "kern.securelevel	integer	raise only
180.It "kern.hostname	string	yes
181.It "kern.hostid	integer	yes
182.It "kern.clockrate	struct	no
183.It "kern.posix1version	integer	no
184.It "kern.ngroups	integer	no
185.It "kern.job_control	integer	no
186.It "kern.saved_ids	integer	no
187.It "kern.boottime	struct	no
188.It "kern.domainname	string	yes
189.It "kern.filedelay	integer	yes
190.It "kern.dirdelay	integer	yes
191.It "kern.metadelay	integer	yes
192.It "kern.osreldate	string	no
193.It "kern.bootfile	string	yes
194.It "kern.corefile	string	yes
195.It "kern.dumpdev	dev_t	yes
196.It "kern.logsigexit	integer	yes
197.It "security.bsd.suser_enabled	integer	yes
198.It "security.bsd.see_other_uids	integer	yes
199.It "security.bsd.unprivileged_proc_debug	integer	yes
200.It "security.bsd.unprivileged_read_msgbuf	integer	yes
201.It "vm.loadavg	struct	no
202.It "hw.machine	string	no
203.It "hw.model	string	no
204.It "hw.ncpu	integer	no
205.It "hw.byteorder	integer	no
206.It "hw.physmem	integer	no
207.It "hw.usermem	integer	no
208.It "hw.pagesize	integer	no
209.It "hw.floatingpoint	integer	no
210.It "hw.machine_arch	string	no
211.It "machdep.console_device	dev_t	no
212.It "machdep.adjkerntz	integer	yes
213.It "machdep.disable_rtc_set	integer	yes
214.It "machdep.guessed_bootdev	string	no
215.It "user.cs_path	string	no
216.It "user.bc_base_max	integer	no
217.It "user.bc_dim_max	integer	no
218.It "user.bc_scale_max	integer	no
219.It "user.bc_string_max	integer	no
220.It "user.coll_weights_max	integer	no
221.It "user.expr_nest_max	integer	no
222.It "user.line_max	integer	no
223.It "user.re_dup_max	integer	no
224.It "user.posix2_version	integer	no
225.It "user.posix2_c_bind	integer	no
226.It "user.posix2_c_dev	integer	no
227.It "user.posix2_char_term	integer	no
228.It "user.posix2_fort_dev	integer	no
229.It "user.posix2_fort_run	integer	no
230.It "user.posix2_localedef	integer	no
231.It "user.posix2_sw_dev	integer	no
232.It "user.posix2_upe	integer	no
233.It "user.stream_max	integer	no
234.It "user.tzname_max	integer	no
235.El
236.Sh EXAMPLES
237For example, to retrieve the maximum number of processes allowed
238in the system, one would use the following request:
239.Pp
240.Dl "sysctl kern.maxproc"
241.Pp
242To set the maximum number of processes allowed
243per uid to 1000, one would use the following request:
244.Pp
245.Dl "sysctl kern.maxprocperuid=1000"
246.Pp
247The device used for crash dumps can be specified using:
248.Pp
249.Dl "sysctl kern.dumpdev=/dev/somedev"
250.Pp
251which is equivalent to
252.Pp
253.Dl "dumpon /dev/somedev"
254.Pp
255Information about the system clock rate may be obtained with:
256.Pp
257.Dl "sysctl kern.clockrate"
258.Pp
259Information about the load average history may be obtained with:
260.Pp
261.Dl "sysctl vm.loadavg"
262.Pp
263More variables than these exist, and the best and likely only place
264to search for their deeper meaning is undoubtedly the source where
265they are defined.
266.Sh FILES
267.Bl -tag -width ".In netinet/icmp_var.h" -compact
268.It In sys/sysctl.h
269definitions for top level identifiers, second level kernel and hardware
270identifiers, and user level identifiers
271.It In sys/socket.h
272definitions for second level network identifiers
273.It In sys/gmon.h
274definitions for third level profiling identifiers
275.It In vm/vm_param.h
276definitions for second level virtual memory identifiers
277.It In netinet/in.h
278definitions for third level Internet identifiers and
279fourth level IP identifiers
280.It In netinet/icmp_var.h
281definitions for fourth level ICMP identifiers
282.It In netinet/udp_var.h
283definitions for fourth level UDP identifiers
284.El
285.Sh COMPATIBILITY
286The
287.Fl w
288option has been deprecated and is silently ignored.
289.Sh SEE ALSO
290.Xr sysctl 3 ,
291.Xr loader.conf 5 ,
292.Xr sysctl.conf 5 ,
293.Xr loader 8
294.Sh BUGS
295The
296.Nm
297utility presently exploits an undocumented interface to the kernel
298sysctl facility to traverse the sysctl tree and to retrieve format
299and name information.
300This correct interface is being thought about for the time being.
301.Sh HISTORY
302A
303.Nm
304utility first appeared in
305.Bx 4.4 .
306.Pp
307In
308.Fx 2.2 ,
309.Nm
310was significantly remodeled.
311