How do sysctl kernel parameters work and what are important tuning examples?
Answer
sysctl reads and writes kernel parameters exposed in /proc/sys/. View all: sysctl -a. Set temporarily: sysctl -w net.ipv4.ip_forward=1. Make permanent: add to /etc/sysctl.conf or a file in /etc/sysctl.d/, then apply with sysctl -p. Critical tuning examples for high-performance servers: net.core.somaxconn=65535 (maximum listen queue depth for TCP servers), net.ipv4.tcp_tw_reuse=1 (reuse TIME_WAIT sockets — reduces port exhaustion), net.ipv4.tcp_fin_timeout=15 (reduce FIN_WAIT2 timeout), vm.swappiness=10 (reduce swapping to prefer RAM), vm.overcommit_memory=1 (used by Redis to allow fork without OOM). Always test sysctl changes in staging — incorrect values can cause kernel panics or network outages.
Previous
How does /etc/fstab work and what are important mount options?
Next
How do you use perf and flame graphs for performance analysis on Linux?
More Linux / Shell Scripting Questions
View all →- Advanced What are Linux namespaces and cgroups, and how do they underpin containers?
- Advanced How do iptables and nftables handle packet filtering rules?
- Advanced What is LVM (Logical Volume Manager) and what problems does it solve?
- Advanced How does /etc/fstab work and what are important mount options?
- Advanced How do you use perf and flame graphs for performance analysis on Linux?