xref: /freebsd/sbin/sysctl/sysctl.8 (revision aa81f3a9d85a26b38316d07ae140c02adf2cb066)
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.\"	$Id: sysctl.8,v 1.14 1997/10/20 12:53:54 charnier Exp $
34.\"
35.Dd September 23, 1994
36.Dt SYSCTL 8
37.Os
38.Sh NAME
39.Nm sysctl
40.Nd get or set kernel state
41.Sh SYNOPSIS
42.Nm sysctl
43.Op Fl bn
44.Ar name ...
45.Nm sysctl
46.Op Fl bn
47.Fl w
48.Ar name=value ...
49.Nm sysctl
50.Op Fl bn
51.Fl aAX
52.Sh DESCRIPTION
53The
54.Nm
55utility retrieves kernel state and allows processes with
56appropriate privilege to set kernel state.
57The state to be retrieved or set is described using a
58``Management Information Base'' (``MIB'') style name,
59described as a dotted set of components.
60.Pp
61The following options are available:
62.Bl -tag -width indent
63.It Fl a
64List all the currently available string or integer values.
65.It Fl A
66List all the known MIB names including opaques.
67Those with string or integer values will be printed as with the
68.Fl a
69flag; for the opaque values,
70information about the format and the length is printed in addition the first
71few bytes is dumped in hex.
72.It Fl X
73Same as
74.Fl A
75except the entire value of opaque variables is hexdumped.
76.It Fl n
77Specify that the printing of the field name should be
78suppressed and that only its value should be output.
79This flag is useful for setting shell variables.
80For example, to save the pagesize in variable psize, use:
81.Bd -literal -offset indent -compact
82set psize=`sysctl -n hw.pagesize`
83.Ed
84.It Fl b
85Force the value of the variable(s) to be output in raw, binary
86format.  No names are printed and no terminating newlines are output.
87This is mostly useful with a single variable.
88.It Fl w Ar name=value ...
89Set the MIB
90.Ar name
91to the new
92.Ar value .
93If just a MIB style
94.Ar name
95is given,
96the corresponding value is retrieved.
97.El
98.Pp
99The information available from
100.Nm
101consists of integers, strings, and opaques.
102.Nm Sysctl
103only knows about a couple of opaque types, and will resort to hexdumps
104for the rest.
105The opaque information is much more useful if retrieved by special
106purpose programs such as
107.Nm ps ,
108.Nm systat ,
109and
110.Nm netstat .
111.Pp
112The string and integer information is summarized below.
113For a detailed description of these variable see
114.Xr sysctl 3 .
115.Pp
116The changeable column indicates whether a process with appropriate
117privilege can change the value.
118.Bl -column net.inet.ip.forwardingxxxxxx integerxxx
119.It Sy Name	Type	Changeable
120.It kern.ostype	string	no
121.It kern.osrelease	string	no
122.It kern.osrevision	integer	no
123.It kern.version	string	no
124.It kern.maxvnodes	integer	yes
125.It kern.maxproc	integer	yes
126.It kern.maxprocperuid	integer	yes
127.It kern.maxfiles	integer	yes
128.It kern.maxfilesperproc	integer	yes
129.It kern.argmax	integer	no
130.It kern.securelevel	integer	raise only
131.It kern.hostname	string	yes
132.It kern.hostid	integer	yes
133.It kern.clockrate	struct	no
134.It kern.posix1version	integer	no
135.It kern.ngroups	integer	no
136.It kern.job_control	integer	no
137.It kern.saved_ids	integer	no
138.It kern.boottime	struct	no
139.It kern.domainname	string	yes
140.It kern.update	integer	yes
141.It kern.osreldate	string	no
142.It kern.bootfile	string	yes
143.It kern.corefile	string	yes
144.It vm.loadavg	struct	no
145.It hw.machine	string	no
146.It hw.model	string	no
147.It hw.ncpu	integer	no
148.It hw.byteorder	integer	no
149.It hw.physmem	integer	no
150.It hw.usermem	integer	no
151.It hw.pagesize	integer	no
152.It hw.floatingpoint	integer	no
153.It hw.machine_arch	string	no
154.It machdep.console_device	dev_t	no
155.It machdep.adjkerntz	integer	yes
156.It machdep.disable_rtc_set	integer	yes
157.It user.cs_path	string	no
158.It user.bc_base_max	integer	no
159.It user.bc_dim_max	integer	no
160.It user.bc_scale_max	integer	no
161.It user.bc_string_max	integer	no
162.It user.coll_weights_max	integer	no
163.It user.expr_nest_max	integer	no
164.It user.line_max	integer	no
165.It user.re_dup_max	integer	no
166.It user.posix2_version	integer	no
167.It user.posix2_c_bind	integer	no
168.It user.posix2_c_dev	integer	no
169.It user.posix2_char_term	integer	no
170.It user.posix2_fort_dev	integer	no
171.It user.posix2_fort_run	integer	no
172.It user.posix2_localedef	integer	no
173.It user.posix2_sw_dev	integer	no
174.It user.posix2_upe	integer	no
175.It user.stream_max	integer	no
176.It user.tzname_max	integer	no
177.El
178.Sh EXAMPLES
179For example, to retrieve the maximum number of processes allowed
180in the system, one would use the follow request:
181.Bd -literal -offset indent -compact
182sysctl kern.maxproc
183.Ed
184.Pp
185To set the maximum number of processes allowed
186in the system to 1000, one would use the follow request:
187.Bd -literal -offset indent -compact
188sysctl -w kern.maxproc=1000
189.Ed
190.Pp
191Information about the system clock rate may be obtained with:
192.Bd -literal -offset indent -compact
193sysctl kern.clockrate
194.Ed
195.Pp
196Information about the load average history may be obtained with:
197.Bd -literal -offset indent -compact
198sysctl vm.loadavg
199.Ed
200.Pp
201More variables than these exist, and the best and likely only place
202to search for their deeper meaning is undoubtedly the source where
203they are defined.
204.Sh FILES
205.Bl -tag -width <netinet/icmpXvar.h> -compact
206.It Pa <sys/sysctl.h>
207definitions for top level identifiers, second level kernel and hardware
208identifiers, and user level identifiers
209.It Pa <sys/socket.h>
210definitions for second level network identifiers
211.It Pa <sys/gmon.h>
212definitions for third level profiling identifiers
213.It Pa <vm/vm_param.h>
214definitions for second level virtual memory identifiers
215.It Pa <netinet/in.h>
216definitions for third level Internet identifiers and
217fourth level IP identifiers
218.It Pa <netinet/icmp_var.h>
219definitions for fourth level ICMP identifiers
220.It Pa <netinet/udp_var.h>
221definitions for fourth level UDP identifiers
222.El
223.Sh SEE ALSO
224.Xr sysctl 3
225.Sh BUGS
226.Nm Sysctl
227presently exploits an undocumented interface to the kernel
228sysctl facility to traverse the sysctl tree and to retrieve format
229and name information.
230This correct interface is being thought about for the time being.
231.Sh HISTORY
232.Nm Sysctl
233first appeared in
234.Bx 4.4 .
235.Pp
236In
237.Fx 2.2 ,
238.Nm
239was significantly remodeled.
240