Introduction
If you are a Linux system administrator, it is essential to modify the behavior of the default kernel. For example, you can make the Kernel accept an increase in the number of connections. Kernels can operate on the interface between the hardware and the operating system but the user cannot be executable with the kernel.
And we will show you how to use the sysctl command in Linux as you go through it below. Hope you understand.
Relationship between kernel and Sysctl
1. Each kernel works with a certain parameter
2. Kernels work with system resources and they can change over time
3. The change of the resource causes the kernel parameters to change as well
4. You can manage kernel configuration and parameters by using the sysctl command
5. We can modify kernel configuration and parameters at runtime by using the sysctl command
Check all the Kernel Parameters
Run sysctl command with option -a:
$ sysctl -a
Output:
Check for a specific single Kernel Parameter
Run the sysctl command with the kernel you need to test. For example, I will check vm.page-cluster kernel:
$ sysctl vm.page-cluster
Output:
If you want to show only the parameter value, add the -n option:
$ sysctl -n vm.page-cluster
Output:
Sysctl command combined with grep command
For example, I show only those kernels that start with vm:
$ sysctl -a | grep vm
Output:
Set up the value of the parameter
The syntax:
$ sysctl -w parameter=value
For example, I want to set up the value of vm.page-cluster as 2:
$ sysctl -w vm.page-cluster=2
Output:
Conclusion
Above is the tutorial about how to use the sysctl command in Linux through examples.
Thanks for reading!