1 .\" $NetBSD: sysctl.8,v 1.160 2009/04/01 15:55:27 christos Exp $
3 .\" Copyright (c) 2004 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
15 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 .\" POSSIBILITY OF SUCH DAMAGE.
28 .\" Copyright (c) 1993
29 .\" The Regents of the University of California. All rights reserved.
31 .\" Redistribution and use in source and binary forms, with or without
32 .\" modification, are permitted provided that the following conditions
34 .\" 1. Redistributions of source code must retain the above copyright
35 .\" notice, this list of conditions and the following disclaimer.
36 .\" 2. Redistributions in binary form must reproduce the above copyright
37 .\" notice, this list of conditions and the following disclaimer in the
38 .\" documentation and/or other materials provided with the distribution.
39 .\" 3. Neither the name of the University nor the names of its contributors
40 .\" may be used to endorse or promote products derived from this software
41 .\" without specific prior written permission.
43 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
44 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
47 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
55 .\" @(#)sysctl.8 8.1 (Berkeley) 6/6/93
57 .Dd September 30, 2009
62 .Nd get or set kernel state
78 .Ar name Ns Li [?]= Ns Ar value ...
97 utility retrieves kernel state and allows processes with
98 appropriate privilege to set kernel state.
99 The state to be retrieved or set is described using a
100 ``Management Information Base'' (``MIB'') style name,
101 described as a dotted set of components.
104 character may also be used as a separator and a leading separator
105 character is accepted.
108 specifies a non-leaf node in the MIB, all the nodes underneath
112 The following options are available:
113 .Bl -tag -width indent
115 List all the known MIB names including tables, unless any MIB
119 Those with string or integer values will be printed as with the
121 flag; for table or structure values that
123 is not able to print,
124 the name of the utility to retrieve them is given.
125 Errors in retrieving or setting values will be directed to stdout
128 List all the currently available string or integer values.
129 The use of a solitary separator character (either
134 itself has the same effect.
137 arguments are ignored if this option is specified.
139 Descriptions of each of the nodes selected will be printed instead of
142 Separate the name and the value of the variable(s) with
144 This is useful for producing output which can be fed back to the
147 This option is ignored if
149 is specified or a variable is being set.
151 Specifies the name of a file to read and process.
152 Blank lines and comments (beginning with
155 Line continuations with
158 Remaining lines are processed similarly to
159 command line arguments of the form
162 .Ar name Ns Li = Ns Ar value .
169 arguments are ignored.
173 print the MIB instead of any of the actual values contained in the
175 This causes the entire MIB to be printed unless specific MIB arguments
180 Specifies that the printing of the field name should be
181 suppressed and that only its value should be output.
182 This flag is useful for setting shell variables.
183 For example, to save the pagesize in variable psize, use:
184 .Bd -literal -offset indent -compact
185 set psize=`sysctl -n hw.pagesize`
188 Used to indicate that nothing should be printed for writes unless an
192 Values printed are in their raw binary forms as retrieved directly
194 Some additional nodes that
196 cannot print directly can be retrieved with this flag.
197 This option conflicts with the
201 Sets the MIB style name given to the value given.
202 The MIB style name and value must be separated by
205 To prevent an error if the MIB style name does not exist (as would be the
206 case with optional kernel components), one can separate the MIB style name
209 Only integral and string values can be set via this method.
213 print the requested value in a hexadecimal representation instead of
215 If specified more than once, the output for each value resembles that of
220 This option conflicts with the
227 top-level MIB has a special semantic: it represent per-process values
228 and as such may differ from one process to another.
229 The second-level name is the pid of the process (in decimal form),
233 .Ql proc. Ns Ao pid Ac Ns .rlimit ,
234 the integer value may be replaced
237 if it matches the magic value used to disable
240 The information available from
242 consists of integers, strings, and tables.
243 The tabular information can only be retrieved by special
244 purpose programs such as
251 for description of available MIBs.
252 .Sh CREATION AND DELETION
253 New nodes are allowed to be created by the superuser when the kernel
254 is running at security level 0.
255 These new nodes may refer to existing kernel data or to new data that
256 is only instrumented by
260 The syntax for creating new nodes is
261 .Dq //create=new.node.path
262 followed by one or more of the following attributes separated by
264 The use of a double separator (both
269 separators) as the prefix tells sysctl that the first series of tokens
270 is not a MIB name, but a command.
271 It is recommended that the double separator preceding the command not
272 be the same as the separator used in naming the MIB entry so as to
273 avoid possible parse conflicts.
276 assigned, if one is given, must be last.
290 If the type is omitted, the
297 asserts the size of the new node.
300 should not have a size set.
301 The size may be omitted for nodes of types
305 If the size is omitted for a node of type
307 the size will be determined by the length of the given value, or by
308 the kernel for kernel strings.
311 must have their size explicitly set.
315 .Ar symbol= Ns Aq Ar A
316 The kernel address of the data being instrumented.
319 is used, the symbol must be globally visible to the in-kernel
324 The MIB number to be assigned to the new node.
325 If no number is specified, the kernel will assign a value.
327 .Ar flags= Ns Aq Ar F
328 A concatenated string of single letters that govern the behavior of
330 Flags currently available are:
333 Allow anyone to write to the node, if it is writable.
339 or the hidden node must be specifically requested in order to see it
342 Makes the node store data in itself, rather than allocating new space
344 This is the default for nodes of type
348 This is the opposite of owning data.
351 When the node is created, separate space will be allocated to store
352 the data to be instrumented.
353 This is the default for nodes of type
357 where it is not possible to guarantee sufficient space to store the
358 data in the node itself.
361 Nodes that are marked private, and children of nodes so marked, are
362 only viewable by the superuser.
363 Be aware that the immediate data that some nodes may store is not
364 necessarily protected by this.
369 default to hexadecimal display of the retrieved value
372 The data instrumented by the given node is read-only.
373 Note that other mechanisms may still exist for changing the data.
374 This is the default for nodes that instrument data.
377 The data instrumented by the given node is writable at any time.
378 This is the default for nodes that can have children.
382 .Ar value= Ns Aq Ar V
383 An initial starting value for a new node that does not reference
384 existing kernel data.
385 Initial values can only be assigned for nodes of the
393 New nodes must fit the following set of criteria:
397 If the new node is to address an existing kernel object, only one of the
401 arguments may be given.
405 type node must be specified; no initial value is expected or permitted.
407 Either the size or the initial value for a
411 The node which will be the parent of the new node must be writable.
414 If any of the given parameters describes an invalid configuration,
416 will emit a diagnostic message to the standard error and exit.
418 Descriptions can be added by the super-user to any node that does not
419 have one, provided that the node is not marked with the
422 The syntax is similar to the syntax for creating new nodes with the
423 exception of the keyword that follows the double separator at the
424 start of the command:
425 .Dq //describe=new.node.path=new node description .
426 Once a description has been added, it cannot be changed or removed.
428 When destroying nodes, only the path to the node is necessary, i.e.,
429 .Dq //destroy=old.node.path .
430 No other parameters are expected or permitted.
431 Nodes being destroyed must have no children, and their parent must be
433 Nodes that are marked with the
435 flag (as assigned by the kernel) may not be deleted.
437 In all cases, the initial
439 that follows the command (eg,
444 may be replaced with another instance of the separator character,
445 provided that the same separator character is used for the length of
446 the name specification.
448 .Bl -tag -width /etc/sysctl.conf -compact
449 .It Pa /etc/sysctl.conf
451 variables set at boot time
454 For example, to retrieve the maximum number of processes allowed
455 in the system, one would use the following request:
456 .Bd -literal -offset indent -compact
460 To set the maximum number of processes allowed
461 in the system to 1000, one would use the following request:
462 .Bd -literal -offset indent -compact
463 sysctl -w kern.maxproc=1000
466 Information about the system clock rate may be obtained with:
467 .Bd -literal -offset indent -compact
468 sysctl kern.clockrate
471 Information about the load average history may be obtained with:
472 .Bd -literal -offset indent -compact
476 To view the values of the per-process variables of the current shell,
478 .Bd -literal -offset indent -compact
481 can be used if the shell interpreter replaces $$ with its pid (this is true
484 To redirect core dumps to the
485 .Pa /var/tmp/ Ns Aq username
487 .Bd -literal -offset indent -compact
488 sysctl -w proc.$$.corename=/var/tmp/%u/%n.core
491 .Bd -literal -offset indent -compact
492 sysctl -w proc.curproc.corename=/var/tmp/%u/%n.core
494 changes the value for the sysctl process itself, and will not have the desired
497 To create the root of a new sub-tree called
499 add some children to the new node, and some descriptions:
500 .Bd -literal -offset indent -compact
501 sysctl -w //create=local
502 sysctl -w //describe=local=my local sysctl tree
503 sysctl -w //create=local.esm_debug,type=int,symbol=esm_debug,flags=w
504 sysctl -w //describe=local.esm_debug=esm driver debug knob
505 sysctl -w //create=local.audiodebug,type=int,symbol=audiodebug,flags=w
506 sysctl -w //describe=local.audiodebug=generic audio debug knob
508 Note that the children are made writable so that the two debug
509 settings in question can be tuned arbitrarily.
511 To destroy that same subtree:
512 .Bd -literal -offset indent -compact
513 sysctl -w //destroy=local.esm_debug
514 sysctl -w //destroy=local.audiodebug
515 sysctl -w //destroy=local