sysctl(8)
View and modify kernel parameters at runtime without reboot.
Synopsis
sysctl [options] [variable[=value]...]Description
sysctl is used to read and write kernel parameters exposed through the /proc/sys interface. These parameters control various aspects of the kernel and networking behavior at runtime, making changes persistent across reboots when written to /etc/sysctl.conf or /etc/sysctl.d/.
Without arguments, sysctl displays all current kernel parameters. You can read individual parameters by name or modify them by assigning a value. Some parameters require root privileges to change.
Common options
| Flag | What it does |
|---|---|
-a | Display all kernel parameters and their values (default behavior) |
-r pattern | Display only parameters matching the given regular expression |
-w | Use assignment format when writing values (variable=value) |
-p | Load settings from /etc/sysctl.conf, /etc/sysctl.d/ and /run/sysctl.d/ |
-e | Ignore errors about unknown variables when setting values |
-n | Print only the values, not the variable names |
-N | Print only variable names, not their values |
--system | Load settings from system directories (same as -p) |
Examples
Display all kernel parameters and their current values
sysctl -aRead and display the current kernel hostname parameter
sysctl kernel.hostnameEnable IP forwarding (allow system to route packets between networks)
sudo sysctl -w net.ipv4.ip_forward=1Search for all IPv4 networking-related kernel parameters
sysctl -a | grep net.ipv4Load and apply all kernel parameters from /etc/sysctl.conf and /etc/sysctl.d/
sudo sysctl -pPrint only the UUID value without the variable name
sysctl -n kernel.random.uuidMake a permanent kernel parameter change and reload configuration
echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.conf && sudo sysctl -pFind all kernel scheduler-related parameters
sysctl -r '^kernel.sched' | grep -v '\.'