What Is sysctl Command In Linux And How To use It

What Is sysctl Command In Linux And How To use It


3 min read

Play this article

What is sysctl command?

In Unix-based operating systems, the sysctl command is a useful tool that enables users to see and alter kernel settings in real time. The sysctl command can access and modify this virtual file system of accessible kernel settings.

You may access details about your system's hardware, networking, and other low-level settings by using the sysctl command. You may also change these settings to enhance system performance or activate particular functionality.

Sysctl is a strong tool for skilled users who wish to optimize the performance of their system or diagnose problems at the kernel level. It should be used cautiously, though, since wrongly changing kernel settings might lead to system instability.

The syntax of the sysctl command:

$ sysctl [options..] [variable..] [value..]

Uses of sysctl command with example

1. How we can see all kernel parameters using sysctl command?

$ sudo sysctl -a

2. How to read kernel parameters using sysctl command?

$ sudo sysctl net.ipv4.conf.all.forwarding

3. How to temporarily modify any kernel parameter's value?

If I want to stop my IP forwarding, I must change the value from 1 to 0 here. If I want to enable it, I must change the number from 0 to 1. You may view the sample below.

$ sudo sysctl -w net.ipv4.conf.all.forwarding=0

As you can see, I have deactivated IP forwarding, but this is not a permanent change; we must also modify the configuration file to make this change permanent.

4. How to modify a kernel parameter's value permanently?

You must visit the /etc/sysctl.conf directory and make the necessary changes there if you wish to permanently alter the kernel parameter value.

$ sudo nvim /etc/sysctl.conf

You may use any text editor here, I am currently using nvim. After opening the config file you need to find/add your kernel parameter and value then save it.

if you want to make your config file you need to add this file in /etc/sysctl.d/your_filename.conf after this you need to run a command.

$ sysctl -p /etc/sysctl.d/your_filename.conf


On Unix-based operating systems, the sysctl command is a potent tool for viewing and changing kernel settings live. It offers a means of optimizing system performance and enabling/disabling particular functionalities. It may be used for everything from memory management to process scheduling, file system settings, and network setup. Its hierarchical tree-like structure facilitates navigation and allows for simple system parameter modification for improved performance. System administrators, programmers, and anybody else who wants to control and improve system performance depend on the sysctl command. you can also check the man page of the sysctl command.

That's all! Thank you for getting this far. I hope you find this article useful. If you did find this article valuable.

Toss us a follow for more amazing articles on Linux, Networking etc

And be sure to share with other Linux folks who you think it might be useful to them.

Did you find this article valuable?

Support Mohit by becoming a sponsor. Any amount is appreciated!