The sysctl
command is used to examine and modify kernel parameters at runtime in Unix-like operating systems. It allows users to view and change system settings that affect the kernel’s behavior without needing to reboot the system.
The basic syntax of the sysctl
command is as follows:
sysctl [options] [arguments]
-a
: Display all current kernel parameters.-w
: Write a new value to a kernel parameter.-n
: Show the value of a kernel parameter without the parameter name.-p
: Load parameters from a specified file.Here are some practical examples of using the sysctl
command:
sysctl -a
sysctl net.ipv4.ip_forward
sysctl -w net.ipv4.ip_forward=1
sysctl -p /etc/sysctl.conf
sysctl -n vm.swappiness
-p
option to apply multiple settings from a configuration file, making it easier to manage system parameters.