sysctl lets you view and modify Linux kernel parameters at runtime — used for tuning networking behavior, memory management, and various system limits without needing a kernel recompile or reboot.
Viewing Current Kernel Parameters
sysctl -a | less
Lists all currently configured kernel parameters — a large list; use grep to find specific ones of interest.
Viewing a Specific Parameter
sysctl net.ipv4.ip_forward
Changing a Parameter Temporarily (Until Reboot)
sudo sysctl -w net.ipv4.ip_forward=1
Making Changes Persistent Across Reboots
sudo nano /etc/sysctl.conf
net.ipv4.ip_forward=1
sudo sysctl -p
sysctl -p reloads settings from the configuration file without requiring a reboot.
Using a Dedicated File Instead of Editing sysctl.conf Directly
sudo nano /etc/sysctl.d/99-custom.conf
Keeps custom settings organized separately from the default configuration, making them easier to manage and review independently.
Common Parameters and What They Control
| Parameter | Purpose |
|---|---|
| net.ipv4.ip_forward | Enable IP forwarding (needed for routing/VPN gateway functionality) |
| vm.swappiness | How aggressively the kernel swaps memory to disk (0-100) |
| net.core.somaxconn | Maximum number of queued network connections |
| fs.file-max | System-wide maximum number of open file handles |
| net.ipv4.tcp_max_syn_backlog | Maximum number of queued SYN requests, relevant for high-connection-rate servers |
Example: Tuning for a High-Traffic Web Server
net.core.somaxconn = 65535
net.ipv4.tcp_max_syn_backlog = 65535
fs.file-max = 2097152
Relevant for servers handling many concurrent connections — default values are conservative and may become a bottleneck under genuinely high load.
Example: Reducing Swap Usage
vm.swappiness = 10
Lower values make the kernel prefer keeping data in RAM over swapping to disk, generally beneficial for performance-sensitive workloads with adequate RAM — see How to Enable and Configure Swap on a Linux VPS for the broader context.
Verifying Changes Took Effect
sysctl net.core.somaxconn
Caution: Understand Before Changing
Kernel parameters can have significant, sometimes non-obvious effects on system behavior and security — research a specific parameter's actual purpose and implications before changing it, rather than applying generic "performance tuning" lists without understanding what each setting does for your specific workload.
Common Errors
"error: permission denied" when setting a parameter — sysctl changes require root/sudo privileges.
Changes don't persist after reboot — verify the setting was added to a configuration file (/etc/sysctl.conf or a file in /etc/sysctl.d/), not just applied temporarily with sysctl -w.
Continue Reading
- How to Enable and Configure Swap on a Linux VPS (Ubuntu & Debian)
- How to Optimize a VPS for High-Traffic E-commerce
- Nginx Performance Tuning: Worker Processes, Caching & Gzip
Browse more articles in Linux Server Administration.