Skip to content

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/:

# View the value of a parameter
cat /proc/sys/net/ipv4/ip_local_port_range

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:

# Increase the maximum number of open files (kernel.shmall)
sysctl kernel.shmall=2097132

To apply changes persistently, edit /etc/sysctl.conf and add the parameter:

# /etc/sysctl.conf example
kernel.shmall = 2097132
net.ipv4.ip_local_port_range = 1024 4096 65535

After saving, apply the configuration with:

sudo sysctl --system

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:

sudo systemctl daemon-reload

Key Takeaways

  • Sysctl parameters are stored in /proc/sys/ and control kernel behavior dynamically.
  • Use sysctl -a to list all parameters and sysctl <parameter> to read/write values.
  • Persistent changes require editing /etc/sysctl.conf or /etc/sysctl.d/ files.
  • Apply persistent configurations with sysctl --system or systemctl daemon-reload.
  • Some parameters may require a reboot or service restart to take effect.