The sysctl
command is used to view and modify kernel parameters at runtime in Linux-based operating systems. It allows users to adjust system settings without needing to reboot, making it a powerful tool for system administrators.
The basic syntax of the sysctl
command is as follows:
sysctl [options] [arguments]
-a
: Display all current kernel parameters.-n
: Show the value of a specific parameter without the parameter name.-w
: Write a new value to a kernel parameter.-p
: Load parameters from a specified file.Here are some practical examples of using the sysctl
command:
sysctl -a
vm.swappiness
):
sysctl -n vm.swappiness
vm.swappiness
to 10):
sysctl -w vm.swappiness=10
/etc/sysctl.conf
):
sysctl -p
net.ipv4.ip_forward
):
sysctl net.ipv4.ip_forward
sysctl -p
to apply changes from a configuration file after editing it./etc/sysctl.conf
for them to survive reboots.