sysctl Parameters
Linux sysctl parameters provide a way to dynamically configure kernel behavior at runtime. These parameters are stored in the /proc/sys/ virtual filesystem, which acts as an interface between user-space tools and the kernel. Each parameter corresponds to a specific kernel module or subsystem, enabling fine-grained control over networking, memory management, process scheduling, and more. Changes to these parameters can be made temporarily via the sysctl command or persistently by configuring /etc/sysctl.conf and using systemd for service-level persistence.
Viewing Sysctl Parameters¶
To inspect current sysctl settings, use the sysctl command or directly read /proc/sys/. For example:
# List all sysctl parameters
sysctl -a
# Check a specific parameter (e.g., network buffer size)
sysctl net.ipv4.tcp_wmem
Alternatively, read values directly from /proc/sys/:
This will output a range like 32768 61000 65535, representing the minimum, default, and maximum port numbers for local TCP/UDP sockets.
Modifying Sysctl Parameters¶
Temporary changes take effect immediately but are lost on reboot. Use the sysctl command with the parameter name and value:
To apply changes persistently, edit /etc/sysctl.conf and add the parameter:
After saving, apply the configuration with:
Systemd automatically loads settings from /etc/sysctl.conf during boot. For service-specific configurations, define custom .conf files in /etc/sysctl.d/ and reload systemd:
Key Takeaways¶
- Sysctl parameters are stored in
/proc/sys/and control kernel behavior dynamically. - Use
sysctl -ato list all parameters andsysctl <parameter>to read/write values. - Persistent changes require editing
/etc/sysctl.confor/etc/sysctl.d/files. - Apply persistent configurations with
sysctl --systemorsystemctl daemon-reload. - Some parameters may require a reboot or service restart to take effect.