sysctl Command in Linux: View and Change Kernel Parameters

The sysctl command lets you view and change Linux kernel parameters from the command line. You can use it to inspect current values, apply temporary changes at runtime, and load persistent settings from configuration files.
This article explains how to use the sysctl command to view, change, and persist kernel parameters in Linux.
Using sysctl to View the Kernel Parameters
To view all current kernel parameters, run sysctl with the -a option:
sysctl -aThis prints a long list where each line includes the parameter name and its value:
abi.vsyscall32 = 1
debug.exception-trace = 1
debug.kprobes-optimization = 1
...All users can view the current kernel parameters; only the root user can modify their values.
You can check the value of a single parameter by passing its name as an argument to sysctl. For example, to check the current swappiness value, run:
sysctl vm.swappinessvm.swappiness = 60Swappiness is a Linux kernel property that defines how often the system will use the swap space .
The sysctl command reads information from the /proc/sys directory. /proc/sys is a virtual directory that contains file objects you can use to view and set current kernel parameters.
You can also view a parameter value by displaying the content of the matching file. The only difference is how the path is represented. For example, both sysctl vm.swappiness and cat /proc/sys/vm/swappiness print the same value. When using sysctl, the directory slashes are replaced with dots and the /proc/sys part is assumed.
Using sysctl to Modify the Kernel Parameters
To set a kernel parameter at runtime, run sysctl followed by the parameter name and value in this format:
sysctl -w parameter=valueIf the value contains spaces or special characters, enclose it in double quotes. You can also pass multiple parameter=value pairs in the same command.
For example, to enable IPv4 packet forwarding, run:
sudo sysctl -w net.ipv4.ip_forward=1The change takes effect immediately, but it is not persistent. After a system reboot, the default value is loaded.
To make a setting persistent, write it to a configuration file in /etc/sysctl.d/:
printf 'net.ipv4.ip_forward = 1\n' | sudo tee /etc/sysctl.d/99-ip-forward.conf > /dev/nullThen reload the configuration:
sudo sysctl --systemAnother way to change parameters is to use the echo
command to write the value directly to a file in /proc/sys. For example:
echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward > /dev/nullThe -p option lets you load settings from a specific configuration file:
sudo sysctl -p /etc/sysctl.d/99-ip-forward.confConclusion
The sysctl command is the standard way to inspect and change Linux kernel parameters from the command line. For persistent changes, store your settings in /etc/sysctl.d/*.conf and reload them after editing.
Tags
Linuxize Weekly Newsletter
A quick weekly roundup of new tutorials, news, and tips.
About the authors

Dejan Panovski
Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.
View author page