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