xref: /freebsd/sbin/sysctl/sysctl.8 (revision afe61c15161c324a7af299a9b8457aba5afc92db)
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.\"	@(#)sysctl.8	8.1 (Berkeley) 6/6/93
33.\"
34.Dd "June 6, 1993"
35.Dt SYSCTL 8
36.Os
37.Sh NAME
38.Nm sysctl
39.Nd get or set kernel state
40.Sh SYNOPSIS
41.Nm sysctl
42.Op Fl n
43.Ar name ...
44.Nm sysctl
45.Op Fl n
46.Fl w
47.Ar name=value ...
48.Nm sysctl
49.Op Fl n
50.Fl aA
51.Sh DESCRIPTION
52The
53.Nm sysctl
54utility retrieves kernel state and allows processes with
55appropriate privilege to set kernel state.
56The state to be retrieved or set is described using a
57``Management Information Base'' (``MIB'') style name,
58described as a dotted set of components.
59The
60.Fl a
61flag can be used to list all the currently available string or integer values.
62The
63.Fl A
64flag will list all the known MIB names including tables.
65Those with string or integer values will be printed as with the
66.Fl a
67flag; for the table values,
68the name of the utility to retrieve them is given.
69.Pp
70The
71.Fl n
72flag specifies that the printing of the field name should be
73suppressed and that only its value should be output.
74This flag is useful for setting shell variables.
75For example, to save the pagesize in variable psize, use:
76.Bd -literal -offset indent -compact
77set psize=`sysctl -n hw.pagesize`
78.Ed
79.Pp
80If just a MIB style name is given,
81the corresponding value is retrieved.
82If a value is to be set, the
83.Fl w
84flag must be specified and the MIB name followed
85by an equal sign and the new value to be used.
86.Pp
87The information available from
88.Nm sysctl
89consists of integers, strings, and tables.
90The tabular information can only be retrieved by special
91purpose programs such as
92.Nm ps ,
93.Nm systat ,
94and
95.Nm netstat .
96The string and integer information is summaried below.
97For a detailed description of these variable see
98.Xr sysctl 3 .
99The changeable column indicates whether a process with appropriate
100privilege can change the value.
101.Bl -column net.inet.ip.forwardingxxxxxx integerxxx
102.It Sy Name	Type	Changeable
103.It kern.ostype	string	no
104.It kern.osrelease	string	no
105.It kern.osrevision	integer	no
106.It kern.version	string	no
107.It kern.maxvnodes	integer	yes
108.It kern.maxproc	integer	yes
109.It kern.maxfiles	integer	yes
110.It kern.argmax	integer	no
111.It kern.securelevel	integer	raise only
112.It kern.hostname	string	yes
113.It kern.hostid	integer	yes
114.It kern.clockrate	struct	no
115.It kern.posix1version	integer	no
116.It kern.ngroups	integer	no
117.It kern.job_control	integer	no
118.It kern.saved_ids	integer	no
119.It kern.link_max	integer	no
120.It kern.max_canon	integer	no
121.It kern.max_input	integer	no
122.It kern.name_max	integer	no
123.It kern.path_max	integer	no
124.It kern.pipe_buf	integer	no
125.It kern.chown_restricted	integer	no
126.It kern.no_trunc	integer	no
127.It kern.vdisable	integer	no
128.It kern.boottime	struct	no
129.It vm.loadavg	struct	no
130.It machdep.console_device	dev_t	no
131.It net.inet.ip.forwarding	integer	yes
132.It net.inet.ip.redirect	integer	yes
133.It net.inet.ip.ttl	integer	yes
134.It net.inet.icmp.maskrepl	integer	yes
135.It net.inet.udp.checksum	integer	yes
136.It hw.machine	string	no
137.It hw.model	string	no
138.It hw.ncpu	integer	no
139.It hw.byteorder	integer	no
140.It hw.physmem	integer	no
141.It hw.usermem	integer	no
142.It hw.pagesize	integer	no
143.It user.cs_path	string	no
144.It user.bc_base_max	integer	no
145.It user.bc_dim_max	integer	no
146.It user.bc_scale_max	integer	no
147.It user.bc_string_max	integer	no
148.It user.coll_weights_max	integer	no
149.It user.expr_nest_max	integer	no
150.It user.line_max	integer	no
151.It user.re_dup_max	integer	no
152.It user.posix2_version	integer	no
153.It user.posix2_c_bind	integer	no
154.It user.posix2_c_dev	integer	no
155.It user.posix2_char_term	integer	no
156.It user.posix2_fort_dev	integer	no
157.It user.posix2_fort_run	integer	no
158.It user.posix2_localedef	integer	no
159.It user.posix2_sw_dev	integer	no
160.It user.posix2_upe	integer	no
161.El
162.Sh EXAMPLES
163.Pp
164For example, to retrieve the maximum number of processes allowed
165in the system, one would use the follow request:
166.Bd -literal -offset indent -compact
167sysctl kern.maxproc
168.Ed
169.Pp
170To set the maximum number of processes allowed
171in the system to 1000, one would use the follow request:
172.Bd -literal -offset indent -compact
173sysctl -w kern.maxproc=1000
174.Ed
175.Pp
176Information about the system clock rate may be obtained with:
177.Bd -literal -offset indent -compact
178sysctl kern.clockrate
179.Ed
180.Pp
181Information about the load average history may be obtained with
182.Bd -literal -offset indent -compact
183sysctl vm.loadavg
184.Ed
185.Sh FILES
186.Bl -tag -width <netinet/icmpXvar.h> -compact
187.It Pa <sys/sysctl.h>
188definitions for top level identifiers, second level kernel and hardware
189identifiers, and user level identifiers
190.It Pa <sys/socket.h>
191definitions for second level network identifiers
192.It Pa <sys/gmon.h>
193definitions for third level profiling identifiers
194.It Pa <vm/vm_param.h>
195definitions for second level virtual memory identifiers
196.It Pa <netinet/in.h>
197definitions for third level Internet identifiers and
198fourth level IP identifiers
199.It Pa <netinet/icmp_var.h>
200definitions for fourth level ICMP identifiers
201.It Pa <netinet/udp_var.h>
202definitions for fourth level UDP identifiers
203.El
204.Sh SEE ALSO
205.Xr sysctl 3
206.Sh HISTORY
207.Nm sysctl
208first appeared in 4.4BSD.
209