|SYSCTL(8)||System Manager's Manual||SYSCTL(8)|
sysctlutility 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.
When retrieving a variable, a subset of the MIB name may be specified to retrieve a list of variables in that subset. For example, to list all the machdep variables:
$ sysctl machdep
When setting a variable, the MIB name should be followed by an equal sign and the new value.
The options are as follows:
-aflag; for the table values, the name of the utility to retrieve them is given.
# set psize=`sysctl -n hw.pagesize`
The information available from
consists of integers, strings, and tables. For a detailed description of the
variables, see sysctl(3).
Tables can only be retrieved by special purpose programs such as
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.mounts
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.
$ sysctl kern.maxproc
To set the maximum number of processes allowed in the system to 1000:
# sysctl kern.maxproc=1000
To retrieve information about the system clock rate:
$ sysctl kern.clockrate
To retrieve information about the load average history:
$ sysctl vm.loadavg
To make the chown(2) system call use traditional BSD semantics (don't clear setuid/setgid bits):
# sysctl fs.posix.setuid=0
To set the list of reserved TCP ports that should not be allocated by the kernel dynamically:
# sysctl net.inet.tcp.baddynamic=749,750,751,760,761,871
# sysctl net.inet.udp.baddynamic=749,750,751,760,761,871,1024-2048
This can be used to keep daemons from stealing a specific port that another program needs to function. List elements may be separated by commas and/or whitespace; a hyphen may be used to specify a range of ports.
It is also possible to add or remove ports from the current list:
# sysctl net.inet.tcp.baddynamic=+748,+6000-6999 # sysctl net.inet.tcp.baddynamic=-871
To set the amount of shared memory available in the system and the maximum number of shared memory segments:
# sysctl kern.shminfo.shmmax=33554432 # sysctl kern.shminfo.shmseg=32
# mkdir -m 700 /var/crash/bgpd # sysctl kern.nosuidcoredump=3
sysctlfirst appeared in 4.4BSD.
|May 4, 2017||OpenBSD-6.2|