-
-
Notifications
You must be signed in to change notification settings - Fork 1
Linux sysctl Guide
Complete beginner-friendly guide to sysctl on Linux, covering Arch Linux, CachyOS, and other distributions including kernel parameters, system tuning, and performance optimization.
- Understanding sysctl
- Viewing Parameters
- Setting Parameters
- Common Parameters
- Performance Tuning
- Troubleshooting
sysctl configures kernel parameters at runtime.
Uses:
- Network tuning: Optimize network performance
- Memory management: Configure memory settings
- Security: Harden system settings
- Performance: Optimize system performance
Why it matters:
- Runtime changes: Modify settings without reboot
- System optimization: Tune for your needs
- Troubleshooting: Fix system issues
View parameters:
# List all parameters
sysctl -a
# List specific category
sysctl -a | grep net
# View single parameter
sysctl kernel.hostnameParameter categories:
# Network parameters
sysctl -a | grep net
# Kernel parameters
sysctl -a | grep kernel
# Virtual memory
sysctl -a | grep vmSet temporarily:
# Set parameter
sudo sysctl kernel.hostname=myhost
# Set network parameter
sudo sysctl net.ipv4.ip_forward=1Note: Changes are lost after reboot.
Make permanent:
# Edit sysctl config
sudo vim /etc/sysctl.confAdd:
# Network forwarding
net.ipv4.ip_forward = 1
# Kernel hostname
kernel.hostname = myhost
Apply:
# Apply changes
sudo sysctl -pNetwork settings:
# Enable IP forwarding
net.ipv4.ip_forward = 1
# Disable ICMP redirects
net.ipv4.conf.all.accept_redirects = 0
# TCP keepalive
net.ipv4.tcp_keepalive_time = 600Memory settings:
# Swappiness (0-100)
vm.swappiness = 10
# Overcommit memory
vm.overcommit_memory = 1Security settings:
# Disable IP source routing
net.ipv4.conf.all.accept_source_route = 0
# Enable SYN cookies
net.ipv4.tcp_syncookies = 1Optimize network:
# Increase TCP buffer sizes
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216Optimize filesystem:
# Increase file handles
fs.file-max = 2097152
# Inotify limits
fs.inotify.max_user_watches = 524288Check configuration:
# Verify parameter
sysctl parameter-name
# Check config file
cat /etc/sysctl.conf
# Apply manually
sudo sysctl -pTest parameter:
# Test before applying
sudo sysctl -w parameter=value
# Check if valid
sysctl parameter-nameThis guide covered sysctl usage, parameter configuration, and system tuning for Arch Linux, CachyOS, and other distributions.
- Performance Tuning - System optimization
- System Configuration - System setup
- Networking - Network configuration
-
sysctl Documentation:
man sysctl
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.