1 .\" $NetBSD: sysctl.8,v 1.162 2011/08/03 01:47:40 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
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 reads or writes unless an
190 For reads, not finding a variable does not print an error, but exits with
192 This is useful just for testing that a variable exists.
195 Values printed are in their raw binary forms as retrieved directly
197 Some additional nodes that
199 cannot print directly can be retrieved with this flag.
200 This option conflicts with the
204 Sets the MIB style name given to the value given.
205 The MIB style name and value must be separated by
208 To prevent an error if the MIB style name does not exist (as would be the
209 case with optional kernel components), one can separate the MIB style name
212 Only integral and string values can be set via this method.
216 print the requested value in a hexadecimal representation instead of
218 If specified more than once, the output for each value resembles that of
223 This option conflicts with the
230 top-level MIB has a special semantic: it represent per-process values
231 and as such may differ from one process to another.
232 The second-level name is the pid of the process (in decimal form),
236 .Ql proc. Ns Ao pid Ac Ns .rlimit ,
237 the integer value may be replaced
240 if it matches the magic value used to disable
243 The information available from
245 consists of integers, strings, and tables.
246 The tabular information can only be retrieved by special
247 purpose programs such as
254 for description of available MIBs.
255 .Sh CREATION AND DELETION
256 New nodes are allowed to be created by the superuser when the kernel
257 is running at security level 0.
258 These new nodes may refer to existing kernel data or to new data that
259 is only instrumented by
263 The syntax for creating new nodes is
264 .Dq //create=new.node.path
265 followed by one or more of the following attributes separated by
267 The use of a double separator (both
272 separators) as the prefix tells sysctl that the first series of tokens
273 is not a MIB name, but a command.
274 It is recommended that the double separator preceding the command not
275 be the same as the separator used in naming the MIB entry so as to
276 avoid possible parse conflicts.
279 assigned, if one is given, must be last.
293 If the type is omitted, the
300 asserts the size of the new node.
303 should not have a size set.
304 The size may be omitted for nodes of types
308 If the size is omitted for a node of type
310 the size will be determined by the length of the given value, or by
311 the kernel for kernel strings.
314 must have their size explicitly set.
318 .Ar symbol= Ns Aq Ar A
319 The kernel address of the data being instrumented.
322 is used, the symbol must be globally visible to the in-kernel
327 The MIB number to be assigned to the new node.
328 If no number is specified, the kernel will assign a value.
330 .Ar flags= Ns Aq Ar F
331 A concatenated string of single letters that govern the behavior of
333 Flags currently available are:
336 Allow anyone to write to the node, if it is writable.
342 or the hidden node must be specifically requested in order to see it
345 Makes the node store data in itself, rather than allocating new space
347 This is the default for nodes of type
351 This is the opposite of owning data.
354 When the node is created, separate space will be allocated to store
355 the data to be instrumented.
356 This is the default for nodes of type
360 where it is not possible to guarantee sufficient space to store the
361 data in the node itself.
364 Nodes that are marked private, and children of nodes so marked, are
365 only viewable by the superuser.
366 Be aware that the immediate data that some nodes may store is not
367 necessarily protected by this.
372 default to hexadecimal display of the retrieved value
375 The data instrumented by the given node is read-only.
376 Note that other mechanisms may still exist for changing the data.
377 This is the default for nodes that instrument data.
380 The data instrumented by the given node is writable at any time.
381 This is the default for nodes that can have children.
385 .Ar value= Ns Aq Ar V
386 An initial starting value for a new node that does not reference
387 existing kernel data.
388 Initial values can only be assigned for nodes of the
396 New nodes must fit the following set of criteria:
400 If the new node is to address an existing kernel object, only one of the
404 arguments may be given.
408 type node must be specified; no initial value is expected or permitted.
410 Either the size or the initial value for a
414 The node which will be the parent of the new node must be writable.
417 If any of the given parameters describes an invalid configuration,
419 will emit a diagnostic message to the standard error and exit.
421 Descriptions can be added by the super-user to any node that does not
422 have one, provided that the node is not marked with the
425 The syntax is similar to the syntax for creating new nodes with the
426 exception of the keyword that follows the double separator at the
427 start of the command:
428 .Dq //describe=new.node.path=new node description .
429 Once a description has been added, it cannot be changed or removed.
431 When destroying nodes, only the path to the node is necessary, i.e.,
432 .Dq //destroy=old.node.path .
433 No other parameters are expected or permitted.
434 Nodes being destroyed must have no children, and their parent must be
436 Nodes that are marked with the
438 flag (as assigned by the kernel) may not be deleted.
440 In all cases, the initial
442 that follows the command (eg,
447 may be replaced with another instance of the separator character,
448 provided that the same separator character is used for the length of
449 the name specification.
451 .Bl -tag -width /etc/sysctl.conf -compact
452 .It Pa /etc/sysctl.conf
454 variables set at boot time
457 For example, to retrieve the maximum number of processes allowed
458 in the system, one would use the following request:
459 .Bd -literal -offset indent -compact
463 To set the maximum number of processes allowed
464 in the system to 1000, one would use the following request:
465 .Bd -literal -offset indent -compact
466 sysctl -w kern.maxproc=1000
469 Information about the system clock rate may be obtained with:
470 .Bd -literal -offset indent -compact
471 sysctl kern.clockrate
474 Information about the load average history may be obtained with:
475 .Bd -literal -offset indent -compact
479 To view the values of the per-process variables of the current shell,
481 .Bd -literal -offset indent -compact
484 can be used if the shell interpreter replaces $$ with its pid (this is true
487 To redirect core dumps to the
488 .Pa /var/tmp/ Ns Aq username
490 .Bd -literal -offset indent -compact
491 sysctl -w proc.$$.corename=/var/tmp/%u/%n.core
494 .Bd -literal -offset indent -compact
495 sysctl -w proc.curproc.corename=/var/tmp/%u/%n.core
497 changes the value for the sysctl process itself, and will not have the desired
500 To create the root of a new sub-tree called
502 add some children to the new node, and some descriptions:
503 .Bd -literal -offset indent -compact
504 sysctl -w //create=local
505 sysctl -w //describe=local=my local sysctl tree
506 sysctl -w //create=local.esm_debug,type=int,symbol=esm_debug,flags=w
507 sysctl -w //describe=local.esm_debug=esm driver debug knob
508 sysctl -w //create=local.audiodebug,type=int,symbol=audiodebug,flags=w
509 sysctl -w //describe=local.audiodebug=generic audio debug knob
511 Note that the children are made writable so that the two debug
512 settings in question can be tuned arbitrarily.
514 To destroy that same subtree:
515 .Bd -literal -offset indent -compact
516 sysctl -w //destroy=local.esm_debug
517 sysctl -w //destroy=local.audiodebug
518 sysctl -w //destroy=local