Skip to content

sysctl Linux Command Guide

The Linux sysctl command allows users to interact with and modify kernel parameters in real-time, providing a way to optimize system performance and behavior. By adjusting various settings, users can fine-tune network configurations, improve security, and troubleshoot issues effectively. This versatile command offers a powerful tool for managing system resources and enhancing overall system stability and efficiency.

Terminal window
sysctl [options] [parameters]
OptionDescription
-a, —allDisplay all parameters
-w, —writeWrite the specified parameter value
-n, —valuesPrint parameter values only
-e, —ignoreIgnore unknown parameters
-q, —quietDo not display error messages
ParameterDescription
kernel.parameter1Description of parameter1
kernel.parameter2Description of parameter2
net.parameter1Description of parameter1
net.parameter2Description of parameter2
Terminal window
sysctl -a

Show all kernel parameters and their current values.

Terminal window
sysctl kernel.hostname

Display the current value of a specific kernel parameter (in this case, “kernel.hostname”).

Terminal window
sysctl -w kernel.pid_max=65536

Update the value of a kernel parameter (in this case, “kernel.pid_max” set to “65536”).

Terminal window
sysctl -p /etc/sysctl.conf

Load sysctl settings from the specified configuration file “/etc/sysctl.conf”.

Terminal window
sysctl -w net.ipv4.ip_forward=1

Change the value of a kernel parameter temporarily (in this case, “net.ipv4.ip_forward” set to “1”).

Terminal window
sysctl --system

Reset all kernel parameters to their default values.

Terminal window
sysctl -a | grep -E "vm.swappiness|net.core.somaxconn"

List the values of specified kernel parameters by filtering the output with grep.

How do I view all kernel parameters using sysctl in Linux?

Section titled “How do I view all kernel parameters using sysctl in Linux?”

To view all kernel parameters using sysctl in Linux, run the following command:

Terminal window
sysctl -a

How do I change a kernel parameter value with sysctl in Linux?

Section titled “How do I change a kernel parameter value with sysctl in Linux?”

To change a kernel parameter value using sysctl in Linux, use the following command syntax:

Terminal window
sysctl <parameter_name>=<new_value>

How do I reload sysctl settings from configuration files in Linux?

Section titled “How do I reload sysctl settings from configuration files in Linux?”

To reload sysctl settings from configuration files in Linux, use the following command:

Terminal window
sysctl --system

How do I search for a specific kernel parameter using sysctl in Linux?

Section titled “How do I search for a specific kernel parameter using sysctl in Linux?”

To search for a specific kernel parameter using sysctl in Linux, you can use the grep command along with sysctl. For example:

Terminal window
sysctl -a | grep <search_term>

How do I apply changes made to the sysctl.conf file in Linux?

Section titled “How do I apply changes made to the sysctl.conf file in Linux?”

To apply changes made to the sysctl.conf configuration file in Linux without rebooting, execute the following command:

Terminal window
sysctl -p

How do I restore the default kernel parameters using sysctl in Linux?

Section titled “How do I restore the default kernel parameters using sysctl in Linux?”

To restore the default kernel parameters using sysctl in Linux, you can reload the sysctl values from configuration files. Run the following command:

Terminal window
sysctl --system
  • Viewing and changing kernel runtime parameters.
  • Managing networking settings.
  • Inspecting and tuning kernel parameters related to memory, processes, and security.
  • Debugging and performance tuning of the Linux kernel.
  • Checking and configuring various system settings like hostname, timezone, etc.