$linuxjunkies
>

sysctl(8)

View and modify kernel parameters at runtime without reboot.

UbuntuDebianFedoraArch

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

FlagWhat it does
-aDisplay all kernel parameters and their values (default behavior)
-r patternDisplay only parameters matching the given regular expression
-wUse assignment format when writing values (variable=value)
-pLoad settings from /etc/sysctl.conf, /etc/sysctl.d/ and /run/sysctl.d/
-eIgnore errors about unknown variables when setting values
-nPrint only the values, not the variable names
-NPrint only variable names, not their values
--systemLoad settings from system directories (same as -p)

Examples

Display all kernel parameters and their current values

sysctl -a

Read and display the current kernel hostname parameter

sysctl kernel.hostname

Enable IP forwarding (allow system to route packets between networks)

sudo sysctl -w net.ipv4.ip_forward=1

Search for all IPv4 networking-related kernel parameters

sysctl -a | grep net.ipv4

Load and apply all kernel parameters from /etc/sysctl.conf and /etc/sysctl.d/

sudo sysctl -p

Print only the UUID value without the variable name

sysctl -n kernel.random.uuid

Make a permanent kernel parameter change and reload configuration

echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Find all kernel scheduler-related parameters

sysctl -r '^kernel.sched' | grep -v '\.'

Related commands