SYSCTL(8) BSD System Manager's Manual SYSCTL(8)
NAME
sysctl -- get or set kernel state
SYNOPSIS
sysctl [-bn] name ...
sysctl [-bn] -w name=value ...
sysctl [-bn] -a
sysctl [-bn] -A
sysctl [-bn] -X
DESCRIPTION
The sysctl utility retrieves kernel state and allows processes with
appropriate privilege to set kernel state. The state to be retrieved or
set is described using a ``Management Information Base'' (``MIB'') style
name, described as a dotted set of components.
The following options are available:
-A List all MIB variables including opaque variables (which are nor-
mally suppressed). The format and length are printed, as well as
a hex dump of the first sixteen bytes of the value.
-a List all the currently available non-opaque values. This option
is ignored if one or more variable names are specified on the
command line.
-b Force the value of the variable(s) to be output in raw, binary
format. No names are printed and no terminating newlines are
output. This is mostly useful with a single variable.
-n Show only variable values, not their names. This option is use-
ful for setting shell variables. For instance, to save the page-
size in variable psize, use:
set psize=`sysctl -n hw.pagesize`
-X Same as -A but prints a hex dump of the entire value instead of
just the first few bytes.
-w name=value
Used to set values. The MIB name ( name ) followed by an equal
sign and the new value ( value ) to be used.
If just a MIB style name is given, the corresponding value is retrieved.
The information available from sysctl consists of integers, strings, and
tables. The tabular information can only be retrieved by special purpose
programs such as ps, systat, and netstat. The string and integer infor-
mation is summarized below. For a detailed description of these variable
see sysctl(3). The changeable column indicates whether a process with
appropriate privilege can change the value.
Name Type Changeable
kern.ostype string no
kern.osrelease string no
kern.osrevision integer no
kern.version string no
kern.maxvnodes integer yes
kern.maxproc integer yes
kern.maxfiles integer yes
kern.argmax integer no
kern.securelevel integer raise only
kern.hostname string yes
kern.hostid integer yes
kern.clockrate struct no
kern.posix1version integer no
kern.ngroups integer no
kern.jobcontrol integer no
kern.savedids integer no
kern.linkmax integer no
kern.maxcanon integer no
kern.maxinput integer no
kern.namemax integer no
kern.pathmax integer no
kern.pipebuf integer no
kern.chownrestricted integer no
kern.notrunc integer no
kern.vdisable integer no
kern.boottime struct no
vm.loadavg struct no
vm.swapusage struct no
machdep.consoledevice devt no
net.inet.ip.forwarding integer yes
net.inet.ip.redirect integer yes
net.inet.ip.ttl integer yes
net.inet.icmp.maskrepl integer yes
net.inet.udp.checksum integer yes
hw.machine string no
hw.model string no
hw.ncpu integer no
hw.byteorder integer no
hw.physmem integer no
hw.usermem integer no
hw.pagesize integer no
user.cspath string no
user.bcbasemax integer no
user.bcdimmax integer no
user.bcscalemax integer no
user.bcstringmax integer no
user.collweightsmax integer no
user.exprnestmax integer no
user.linemax integer no
user.redupmax integer no
user.posix2version integer no
user.posix2cbind integer no
user.posix2cdev integer no
user.posix2charterm integer no
user.posix2fortdev integer no
user.posix2fortrun integer no
user.posix2localedef integer no
user.posix2swdev integer no
user.posix2upe integer no
The sysctl program can get or set debugging variables that have been
identified for its display. This information can be obtained by using
the command:
sysctl debug
In addition, sysctl can extract information about the filesystems that
have been compiled into the running system. This information can be
obtained by using the command:
sysctl vfs
By default, only filesystems that are actively being used are listed.
Use of the -A flag lists all the filesystems compiled into the running
kernel.
EXAMPLES
For example, to retrieve the maximum number of processes allowed in the
system, one would use the follow request:
sysctl kern.maxproc
To set the maximum number of processes allowed in the system to 1000, one
would use the follow request:
sysctl -w kern.maxproc=1000
Information about the system clock rate may be obtained with:
sysctl kern.clockrate
Information about the load average history may be obtained with:
sysctl vm.loadavg
Information about the system's swap space usage may be obtained with:
sysctl vm.swapusage
FILES
definitions for top level identifiers, second level
kernel and hardware identifiers, and user level
identifiers
definitions for second level network identifiers
definitions for third level profiling identifiers
definitions for second level virtual memory identi-
fiers
definitions for third level Internet identifiers
and fourth level IP identifiers
definitions for fourth level ICMP identifiers
definitions for fourth level UDP identifiers
SEE ALSO
sysctl(3)
HISTORY
sysctl first appeared in 4.4BSD.
BSD March 6, 2010 BSD
|