3

We have a Linux machine (Redhat 6)

When we print all parameters from /etc/sysctl.conf we see only ~20 but when we perform sysctl -a we see more than 200.

So from where sysctl -a print all these parameters ?

Or for example when we do

sysctl -w variable=value

how to know where the variable should be saved?

How to know each parameters if it is dynamic or static?

2

Sysctl settings are stored in the kernel. These settings influence kernel behavior; basically, they're variables of the kernel which programs running on the system can read and write.

When the kernel boots, each sysctl setting has a default value. This value can be changed at any time by a program such as the sysctl command, or, under Linux, by writing to the corresponding file under /proc/sys.

The file /etc/sysctl.conf does not determine the value of the settings at run time. It's only used at boot time, to change some settings from the default value compiled into the kernel. If you've made some changes to /etc/sysctl.conf, you can apply them as a whole by restarting the sysctl “service” — the sysctl service doesn't correspond to a running process, it's a pseudo-service that just loads the settings into the kernel when it starts.

If you want to change a setting so that the value is preserved across reboots, add it to /etc/sysctl.conf. To apply a setting temporarily or to try it out, use sysctl or echo … >/proc/sys/….

0

How to know each parameter if it is dynamic or static?

All the kernel parameters in sysctl are dynamic. When you check the number depending on your kernel version sysctl -a | wc -l it should be more than 1000.

To read the values you have several smart options:

sysctl net.ipv4.ip_forward          # display specific parameter
sysctl net.ipv4                     # display all net.ipv4.* parameters
sysctl -a                           # display all parameters

And to write the values persistently you can use /etc/sysctl.conf or any conf file inside /etc/sysctl.d/ directory, and once you update the conf file you need to reload the configuration file.

sysctl -p [filename]

Of course, you can just restart the the sysctl “service” as Gilles outlined.

From where does sysctl -a print all kernel parameters?

From the pseudo file system procfs (man procfs). It provides an interface to kernel data structures. It is commonly mounted at /proc automatically by the system.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.