Manual nsysctl version 2

Posted on 2021-03-07 - Updated on 2022-01-02

The nsysctl utility can get or set the FreeBSD kernel state at runtime, this is the manual; a tutorial is available, too.

NSYSCTL(8)              FreeBSD System Manager's Manual             NSYSCTL(8)

NAME
     nsysctl - get or set system state

SYNOPSIS
     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

DESCRIPTION
     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):

           sysctlinfo_load="YES"

     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, if the value is 0 becomes 1, if
             it is not 0 becomes 0, if the value is an array only the first
             index takes effect.

EXIT STATUS
     The nsysctl utility exits 0 on success, and >0 if an error occurs.

EXAMPLES
     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

COMPATIBILITY
     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

SEE ALSO
     sysctl(3), sysctlmibinfo2(3), xo_parse_args(3), sysctlinfo(4), sysctl(8)

HISTORY
     The nsysctl utility first appeared in FreeBSD 13.0.

AUTHORS
     nsysctl was written by Alfonso Sabato Siciliano
     <alf.siciliano@gmail.com>.

FreeBSD 14.0-CURRENT            January 2, 2022            FreeBSD 14.0-CURRENT