Sysctl: Difference between revisions

From Helpful
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
Line 57: Line 57:
* /proc/sys
* /proc/sys
: In Linux, the sysctl interface mechanism is also present in /proc/sys
: In Linux, the sysctl interface mechanism is also present in /proc/sys
<code lang="bash">
<syntaxhighlight lang="bash">
# readout:
# readout:
cat /proc/sys/net/ipv4/ip_forward
cat /proc/sys/net/ipv4/ip_forward
# change (when supported for the variable)
# change (when supported for the variable)
echo "1" > /proc/sys/net/ipv4/ip_forward
echo "1" > /proc/sys/net/ipv4/ip_forward
</code>
</syntaxhighlight >
: Some old distros did not have sysctl, and this was the main way to go for on-the-fly changes.
: Some old distros did not have sysctl, and this was the main way to go for on-the-fly changes.




* {{inlinecode|sysctl}} command
* {{inlinecode|sysctl}} command
<code lang="bash">
<syntaxhighlight lang="bash">
# readout:
# readout:
sysctl net.ipv4.ip_forward
sysctl net.ipv4.ip_forward
# change (whensupported for the variable)
# change (whensupported for the variable)
sysctl -w net.ipv4.ip_forward=1
sysctl -w net.ipv4.ip_forward=1
</code>
</syntaxhighlight >


-->
-->

Latest revision as of 15:52, 11 September 2023


sysctl is a *nix concept, which tweaks parameters of in-kernel systems.


Linux also exposes sysctl as a virtual file system at /proc/sys, so e.g. reading out

sysctl net.ipv4.ip_forward
sysctl -w net.ipv4.ip_forward=1

can also be done like

cat /proc/sys/net/ipv4/ip_forward
echo 1>/proc/sys/net/ipv4/ip_forward


There is also an on-filesystem set of files that present what should be set at boot

Best known is probably

/etc/sysctl.conf




To see what kind of parameters, see current values using:

sysctl -a