sysctl
Modify kernel parameters at runtime
TLDR
Show all available variables and their values
Set a changeable kernel state variable
Get currently open file handlers
Get limit for simultaneous open files
Apply changes from /etc/sysctl.conf
SYNOPSIS
sysctl [options] [variable[=value]...]
sysctl -a
sysctl net.ipv4.ip_forward
sysctl net.ipv4.ip_forward=1
PARAMETERS
-a, --all
Display all currently available kernel parameters and their values.
-e, --pattern pattern
Display all parameters matching the specified pattern. Wildcards like '*' can be used.
-w, --write
Enable writing of sysctl values, even if the value contains a colon. Often implied when setting a value directly.
-p, --load
Load parameters from default sysctl configuration files (e.g., /etc/sysctl.conf and files in /etc/sysctl.d/).
-r, --print-write
Only print parameters that are writable.
-n, --values
Do not print variable names, only print their values.
-N, --names
Do not print values, only print variable names.
-X, --deprecated
Include deprecated parameters in the listing output.
-q, --quiet
Do not print errors about unknown keys.
-v, --version
Display version information and exit.
-h, --help
Display a brief help message and exit.
DESCRIPTION
sysctl is a command-line utility used to view and modify kernel parameters at runtime on Linux systems. These parameters reside in the virtual /proc/sys filesystem and control various aspects of the kernel's behavior, including network stack settings, virtual memory management, security features, and general system performance. System administrators frequently use sysctl to fine-tune a system's operation without needing to reboot or recompile the kernel. It offers a convenient interface to list all available parameters, query the current value of a specific parameter, or set a new value for a writable parameter. Changes made interactively with sysctl are temporary and will not persist across system reboots. For permanent modifications, parameters must be configured in files like /etc/sysctl.conf or within the /etc/sysctl.d/ directory, which are loaded automatically during system startup.
CAVEATS
Changes made with sysctl directly on the command line are not persistent across reboots unless explicitly saved in configuration files like /etc/sysctl.conf or those in /etc/sysctl.d/.
Incorrectly modifying kernel parameters can lead to system instability, performance degradation, or introduce security vulnerabilities. Always understand the implications of a parameter before changing its value.
Some parameters are read-only or require root privileges to modify.
CONFIGURATION FILES
For persistent changes, kernel parameters should be configured in /etc/sysctl.conf or in separate .conf files placed in the /etc/sysctl.d/ directory. These files are typically loaded automatically at boot time by system initialization scripts or services (e.g., systemd-sysctl.service).
/PROC/SYS FILESYSTEM
sysctl directly interacts with the pseudo-filesystem /proc/sys. Each kernel parameter corresponds to a file within this directory structure (e.g., net.ipv4.ip_forward maps to /proc/sys/net/ipv4/ip_forward). Reading from or writing to these files manually via commands like cat or echo has the same effect as using the sysctl command.
HISTORY
The ability to dynamically adjust kernel behavior is a long-standing feature in Unix-like operating systems. On Linux, sysctl serves as the primary user-space interface for interacting with kernel parameters exposed through the /proc/sys filesystem, which became a standard way to manage these tunable settings. Its development focused on providing system administrators with a consistent and easy-to-use tool to inspect and modify kernel states without requiring a system restart, significantly enhancing system flexibility and manageability.
SEE ALSO
proc(5), sysctl.conf(5), ip(8), tuned(8)