sysctl(8) is used to make changes to a running FreeBSD system. This includes many advanced options of the TCP/IP stack and virtual memory system that can dramatically improve performance for an experienced system administrator. Over five hundred system variables can be read and set using sysctl(8).
At its core, sysctl(8) serves two functions: to read and to modify system settings.
To view all readable variables:
%
sysctl -a
To read a particular variable, specify its name:
%
sysctl kern.maxproc
kern.maxproc: 1044
To set a particular variable, use the
variable
=value
syntax:
#
sysctl kern.maxfiles=5000
kern.maxfiles: 2088 -> 5000
Settings of sysctl variables are usually either strings,
numbers, or booleans, where a boolean is 1
for yes or 0
for no.
To automatically set some variables each time the machine
boots, add them to /etc/sysctl.conf
. For
more information, refer to sysctl.conf(5) and
Section 12.9.1, “sysctl.conf
”.
The configuration file for sysctl(8),
/etc/sysctl.conf
, looks much like
/etc/rc.conf
. Values are set in a
variable=value
form. The specified values
are set after the system goes into multi-user mode. Not all
variables are settable in this mode.
For example, to turn off logging of fatal signal exits
and prevent users from seeing processes started by other
users, the following tunables can be set in
/etc/sysctl.conf
:
# Do not log fatal signal exits (e.g., sig 11) kern.logsigexit=0 # Prevent users from seeing information about processes that # are being run under another UID. security.bsd.see_other_uids=0
In some cases it may be desirable to modify read-only sysctl(8) values, which will require a reboot of the system.
For instance, on some laptop models the cardbus(4) device will not probe memory ranges and will fail with errors similar to:
cbb0: Could not map register memory device_probe_and_attach: cbb0 attach returned 12
The fix requires the modification of a read-only
sysctl(8) setting. Add
hw.pci.allow_unsupported_io_range=1
to
/boot/loader.conf
and reboot. Now
cardbus(4) should work properly.
All FreeBSD documents are available for download at http://ftp.FreeBSD.org/pub/FreeBSD/doc/
Questions that are not answered by the
documentation may be
sent to <[email protected]>.
Send questions about this document to <[email protected]>.