Editing Sysctl

Jump to: navigation, search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 4: Line 4:
 
==Introduction==
 
==Introduction==
 
The [https://www.freebsd.org/cgi/man.cgi?query=sysctl&apropos=0&sektion=0&manpath=FreeBSD+12.1-RELEASE+and+Ports&arch=default&format=html 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.<br/>
 
The [https://www.freebsd.org/cgi/man.cgi?query=sysctl&apropos=0&sektion=0&manpath=FreeBSD+12.1-RELEASE+and+Ports&arch=default&format=html 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.<br/>
 
==Retrieve Kernel Information==
 
  
 
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 [https://www.freebsd.org/cgi/man.cgi?query=ps&sektion=1&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports  ps(1)], [https://www.freebsd.org/cgi/man.cgi?query=systat&sektion=1&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports systat(1)], and [https://www.freebsd.org/cgi/man.cgi?query=netstat&sektion=1&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports netstat(1)].
 
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 [https://www.freebsd.org/cgi/man.cgi?query=ps&sektion=1&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports  ps(1)], [https://www.freebsd.org/cgi/man.cgi?query=systat&sektion=1&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports systat(1)], and [https://www.freebsd.org/cgi/man.cgi?query=netstat&sektion=1&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports netstat(1)].
Line 11: Line 9:
 
Some of the variables which cannot be modified during normal system operation can be initialized via [https://www.freebsd.org/cgi/man.cgi?query=loader&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports loader(8)] tunables.  This can for example be  done by setting them in [https://www.freebsd.org/cgi/man.cgi?query=loader.conf&sektion=5&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports loader.conf(5)].  Please refer to [https://www.freebsd.org/cgi/man.cgi?query=loader.conf&sektion=5&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports loader.conf(5)]  for more information on which tunables are available and how to set them.
 
Some of the variables which cannot be modified during normal system operation can be initialized via [https://www.freebsd.org/cgi/man.cgi?query=loader&sektion=8&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports loader(8)] tunables.  This can for example be  done by setting them in [https://www.freebsd.org/cgi/man.cgi?query=loader.conf&sektion=5&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports loader.conf(5)].  Please refer to [https://www.freebsd.org/cgi/man.cgi?query=loader.conf&sektion=5&apropos=0&manpath=FreeBSD+12.1-RELEASE+and+Ports 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:
+
==Usage==
  
<code>sysctl NAME</code>
+
The following list is only an excerpt.
  
You will get the following examples:
+
Use '''sysctl''' plus the following NAME
  
 
{|class="wikitable" style="width:96.5%;background:#FFFFFF; border:2px solid #008000;text-align:left;padding: 10px"  
 
{|class="wikitable" style="width:96.5%;background:#FFFFFF; border:2px solid #008000;text-align:left;padding: 10px"  
 
|-
 
|-
 
! scope="col" style="width: 100px;"|'''NAME'''
 
! scope="col" style="width: 100px;"|'''NAME'''
! scope="col" style="width: 350px;"|'''Output on GhostBSD'''  
+
! scope="col" style="width: 350px;"|'''Description'''  
 
|-
 
|-
 
|kern.ostype||FreeBSD
 
|kern.ostype||FreeBSD
Line 28: Line 26:
 
|kern.osrevision||199506
 
|kern.osrevision||199506
 
|-
 
|-
|kern.osreldate ||1201512 (kernel release date)<br/>You get the same result with the command: <code>uname -U</code>
+
|kern.osreldate ||1201512 <br/>You get the same result with the command: uname -U
 
|-
 
|-
 
|kern.version ||FreeBSD 12.1-STABLE GENERIC
 
|kern.version ||FreeBSD 12.1-STABLE GENERIC
Line 75: Line 73:
  
 
|}
 
|}
 
==Categories of Kernel information==
 
 
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.
 
 
{|class="wikitable" style="width:96.5%;background:#FFFFFF; border:2px solid #008000;text-align:left;padding: 10px"
 
|-
 
! scope="col" style="width: 100px;"|'''Category'''
 
! scope="col" style="width: 350px;"|'''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.<br/>
 
'''Example:''' the category ''kern'' and its subcategory ''hostname'' give you: ''kern.hostname'' a unique sysctl variable.
 
 
==Retrieve Definition of a sysctl Variable==
 
 
If you like to know how is the sysctl variable defined, you have to use the following command:
 
 
<code>sysctl -d NAME</code>
 
 
'''Example''':
 
 
<code>sysctl -d kern.osreldate</code>
 
 
You will get:
 
 
''kern.osreldate: Kernel release date''
 
 
For more sysctl options look at [https://www.freebsd.org/cgi/man.cgi?query=sysctl&apropos=0&sektion=0&manpath=FreeBSD+12.1-RELEASE+and+Ports&arch=default&format=html sysctl] on the man pages.
 
 
Unfortunately not all sysctl variables provide definitions with ''-d''.
 
 
More variables than in [https://www.freebsd.org/cgi/man.cgi?query=sysctl&apropos=0&sektion=0&manpath=FreeBSD+12.1-RELEASE+and+Ports&arch=default&format=html 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==
 
 
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:
 
 
<code>sysctl hw</code>
 
 
If you try it, you will get a lot of answers. You can limit it for example to ''hw.usb'':
 
 
<code>sysctl hw.usb</code>
 
 
You will see the MIB tree shows further subcategories like
 
 
''hw.usb.timings.extra_power_up_time: 20''
 
 
==Changing sysctl Variables==
 
 
If you look in the [https://www.freebsd.org/cgi/man.cgi?query=sysctl&apropos=0&sektion=0&manpath=FreeBSD+12.1-RELEASE+and+Ports&arch=default&format=html 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 [https://www.freebsd.org/cgi/man.cgi?query=sysctl&apropos=0&sektion=0&manpath=FreeBSD+12.1-RELEASE+and+Ports&arch=default&format=html sysctl(8)] command.
 
 
'''For example:'''
 
If you look into the MIB tree for vfs with
 
 
<code>sysctl vfs</code>
 
 
and you see vfs.usermount: 0 The value says you can not mount. You have to set the value to 1 by the command:
 
 
<code><nowiki>#</nowiki>sysctl vfs.usermount=1</code>
 
 
You set the value to 1.
 
 
The sysctl program responds to you set the old value 0 to the new value 1:
 
 
<code>vfs.usermount: 0->1</code>
 
 
==Remaining the Chang of sysctl Variables after reboot ==
 
 
Use the file /etc/sysctl.conf. Insert the line
 
 
<code>vfs.usermount=1</code>
 
 
  
  
 
[[Category:How To]]
 
[[Category:How To]]
 
[[Category:Kernel]]
 
[[Category:Kernel]]

Please note that all contributions to GhostBSD Wiki are considered to be released under the Creative Commons Attribution (see GhostBSD Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel | Editing help (opens in new window)