nsysctl — get or
set system state
nsysctl |
[--libxo options
[-r tagroot]]
[-DdeFGgHIilnOpqTtvWz] [-N
| -h [b |
o | x]]
[-B bufsize]
[-s sep]
[-f filename]
name[=value[,value]]
... |
nsysctl |
[--libxo options
[-r tagroot]]
[-DdeFGgHIklnOpqSTtvWz]
[-N | -Vh
[b | o |
x]] [-B
bufsize] [-s
sep] -a |
The nsysctl utility can get or set the
state of the System at runtime. The System exposes the available parameters
as objects of a “Management Information Base” (MIB),
nsysctl can explore the MIB, print the properties of
an object, get or set its value and show the output in human and machine
readable formats.
An object is identified by an Object Identifier (OID), a series of
numbers, it is possible to replace a number with a string to obtain an
object name, e.g., [1.1] → “kern.ostype”,
nsysctl can receive in input one or more
name, eventually with a new
value, or -a for all
objects.
nsysctl requires the
sysctlinfo(4)
interface. To load the required kernel module at boot time, place the
following line in
loader.conf(5):
The following options are available:
--libxo
options
- Generate output via
libxo(3)
in a selection of different human and machine readable formats, see
xo_parse_args(3).
-A
- Equivalent to
-a -o,
obsolete.
-a
- Display all objects.
-b
- Print value in binary format.
-B
<bufsize>
- use a buffer of <bufsize> bytes.
-D
- Equivalent to
-d -F
-G -H
-l -O
-t.
-d
- Show description.
-e
- Use “=” as separator.
-F
- Display format string.
-f
<filename>
- Load objects from <filename>.
-G
- Show true flags.
-g
- Print flags.
-H
- Show the object handler status.
-h
- Try to show values in a human-friendly format.
-I
- Show internal nodes, only leaves are printed by default.
-i
- Ignore unknown objects.
-k
- Show object with
SKIP flag with
-a.
-l
- Print aggregation label.
-m
- Alias for
-S.
-N
- Hide value.
-n
- Hide name.
-O
- Display OID.
-o
- Show value in hex format until 16 bytes.
-p
- Display [ “PROPERTY-NAME” ]:
“property-value”.
-q
- Avoid to show some warning.
-r
<tagroot>
- Specify a <tagroot> with libxo.
-S
- Display also the “sysctl.*” subtree with
-a.
-s
<sep>
- Use <sep> as separator.
-T
- Show only settable objects via loader.
-t
- Print type.
-V
- By default
-a hides an object without a value,
this option disable this feature.
-v
nsysctl version.
-W
- Display only writable objects that are not statistical.
-X
- Equivalent to
-a -x,
obsolete.
-x
- Print value in hex format.
-y
- Alias for
-O.
-z
- Toggle numeric or boolean value.
0 becomes
1, any value other than 0
becomes 1. Only the first element of an array is
switched.
The nsysctl utility exits 0 on
success, and >0 if an error occurs.
To get an object value:
nsysctl kern.hostname
To set an object value:
nsysctl
kern.hostname=myBSD
Print object info:
nsysctl -pD kern.ostype
Print object info in xml:
nsysctl --libxo=xml,pretty -D
kern.ostype
sysctl(8)
prints internal and SKIP nodes with
-aN, -ad and
-at, only leaves avoiding
SKIP nodes otherwise, to reproduce with
nsysctl:
/sbin/sysctl /usr/local/sbin/nsysctl
% sysctl -aN % nsysctl -aNIk
% sysctl -ad % nsysctl -adIk
% sysctl -at % nsysctl -atIk