×


sysctl command in Linux - Explained with examples

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.

Basically, sysctl helps to list and modify kernel runtime variables in a Linux system.

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform related Linux system commands queries.

In this context, we shall look into how to use the sysctl command in Linux.


Relationship between kernel and Sysctl

  • Each kernel works with a certain parameter.
  • Kernels work with system resources and they can change over time.
  • The change of the resource causes the kernel parameters to change as well.
  • You can manage kernel configuration and parameters by using the sysctl command.
  • We can modify kernel configuration and parameters at runtime by using the sysctl command.


How to check all the Kernel Parameters ?

You can Run sysctl command with option -a:

$ sysctl -a


How to Check for a specific single Kernel Parameter ?

Run the sysctl command with the kernel you need to test. For example, We will check vm.page-cluster kernel:

$ sysctl vm.page-cluster

If you want to show only the parameter value, add the -n option:

$ sysctl -n vm.page-cluster


Sysctl command combined with grep command

For example, We show only those kernels that start with vm:

$ sysctl -a | grep vm


How to Set up the value of the parameter ?

The syntax:

$ sysctl -w parameter=value

For example, We want to set up the value of vm.page-cluster as 2:

$ sysctl -w vm.page-cluster=2


[Need help in fixing Linux system issues? We can help you. ]


Conclusion

This article covers how to use the sysctl command in Linux through examples. In fact, sysctl is used to modify kernel parameters at runtime. The parameters available are those listed under /proc/sys/. Procfs is required for sysctl support in Linux.