From GhostBSD Wiki
Jump to: navigation, search
Welcome to Icon Disti GhostBSD.png Sysctl.
Kernel Competence
Sysctl Kldstat Third-party Kernel Modules
Kernel Modules FreeBSD Ports: Kld Kenv
Compiling a new GhostBSD kernel
Back to the Icon Disti GhostBSD.pngSystem


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.

Retrieve Kernel Information[edit]

The information available from sysctl consists of integers, strings, and opaque types. The sysctl utility only knows about a couple of opaque types, and will resort to hexdumps for the rest. The opaque information is much more useful if retrieved by special purpose programs such as ps(1), systat(1), and netstat(1).

Some of the variables which cannot be modified during normal system operation can be initialized via loader(8) tunables. This can for example be done by setting them in loader.conf(5). Please refer to loader.conf(5) for more information on which tunables are available and how to set them.

To retrieve kernel information use sysctl plus the following sysctl variable NAME:

sysctl NAME

You will get the following examples:

NAME Output on GhostBSD
kern.ostype FreeBSD
kern.osrelease 12.1-STABLE
kern.osrevision 199506
kern.osreldate 1201512 (kernel release date)
You get the same result with the command: uname -U
kern.version FreeBSD 12.1-STABLE GENERIC
kern.hostname slughorn.ghostbsd-pc.home
kern.clockrate { hz = 1000, tick = 1000, profhz = 8128, stathz = 127
kern.boottime Fri Feb 21 18:58:27 2020 (example)
kern.bootfile /boot/kernel/kernel
kern.corefile %N.core
kern.logsigexit 1
security.bsd.suser_enabled 1
security.bsd.see_other_uids 1
security.bsd.unprivileged_proc_debug 1
security.bsd.unprivileged_read_msgbuf 1
vm.loadavg { 0,59 0,52 0,54 }
hw.machine amd64
hw.model AMD Athlon(tm) 64 X2 Dual Core Processor 6000+
hw.ncpu 2
hw.byteorder 1234
hw.physmem 3972182016
hw.usermem 3445424128
hw.machine_arch amd64
hw.realmem 4294967296
user.cs_path /usr/bin:/bin:/usr/sbin:/sbin
Back to Icon Disti GhostBSD.pngHow To

Categories of Kernel information[edit]

The kernel information are organized in a tree format, called as management information base (MIB) with several categories. Compare the following list with the NAMEs above.

Category Function
kern Core kernel funktions and features
vm Virtual memory system
vfs Filesystem
net Networking
debug Debugging
hw Hardware
machdep Machine-depend settings
user Userland interface information
p1003_1b POSIX behavior
dev Device-specific information
security Security-specific kernel features

Each of this categories have further subcategories. Each category is connected with its subcategories by making a string with a point between them.
Example: the category kern and its subcategory hostname give you: kern.hostname a unique sysctl variable.

Retrieve Definition of a sysctl Variable[edit]

If you like to know how is the sysctl variable defined, you have to use the following command:

sysctl -d NAME


sysctl -d kern.osreldate

You will get:

kern.osreldate: Kernel release date

For more sysctl options look at sysctl on the man pages.

Unfortunately not all sysctl variables provide definitions with -d.

More variables than in sysctl(8) exist and the best and likely only place to search for their deeper meaning is undoubtedly the source where they are defined.

View all the MIB available Variables[edit]

If you like to view all the MIBs available in a particular sub-tree of the MIB tree, use the sysctl command with the name of the part of the tree you want to see. For example you want to see everything under hw write the command:

sysctl hw

If you try it, you will get a lot of answers. You can limit it for example to hw.usb:

sysctl hw.usb

You will see the MIB tree shows further subcategories like

hw.usb.timings.extra_power_up_time: 20

Changing sysctl Variables[edit]

If you look in the sysctl(8) man pages, you will see a table. Some variables are changeable and some not. GhostBSD/FreeBSD protects you to crash you system. therefor are some variables not changeable.

To change a value of a sysctl variable you can use the sysctl(8) command.

For example: If you look into the MIB tree for vfs with

sysctl vfs

and you see vfs.usermount: 0 The value says you can not mount. You have to set the value to 1 by the command:

#sysctl vfs.usermount=1

You set the value to 1.

The sysctl program responds to you set the old value 0 to the new value 1:

vfs.usermount: 0->1

Remaining the Chang of sysctl Variables after reboot[edit]

Use the file /etc/sysctl.conf. Insert the line