Read and write kernel parameters at runtime.
high risk
sysctl -n <key>Note the current value before changing it.sysctl --systemReload from config files to undo runtime experiments.sysctl reads and modifies kernel parameters in /proc/sys/ at runtime. Changes are immediate but not persistent unless written to /etc/sysctl.conf or /etc/sysctl.d/. Used for tuning network stack, enabling IP forwarding, configuring VM behavior, and hardening.
| Flag | Meaning |
|---|---|
-a --all | Print all kernel parameters |
-w --write | Set a parameter value |
-p --load | Load from a file (default: /etc/sysctl.conf) |
-n --values | Print only the value, not the name |
sysctl -a | grep net.ipv4.ip_forwardCheck if IP forwarding is enabled · explain & risk-check →sysctl -w net.ipv4.ip_forward=1Enable IP forwarding (not persistent) · explain & risk-check →sysctl net.core.somaxconnCheck max socket listen queue · explain & risk-check →sysctl -p /etc/sysctl.d/99-custom.confApply custom sysctl config file · explain & risk-check →For K8s nodes, always verify: `sysctl net.bridge.bridge-nf-call-iptables=1` and `net.ipv4.ip_forward=1`. Missing these causes pod networking failures that are hard to trace.
Reference text is hand-written and may be incomplete — check man sysctl for your version. Test destructive commands on a non-production system first.