What's the prescribed way to set Linux kernel runtime parameters? I've seen sometimes that people will set these in files such as /etc/rc.local
.
Is this really the right way to do this?
kernellinuxparametersysctl
What's the prescribed way to set Linux kernel runtime parameters? I've seen sometimes that people will set these in files such as /etc/rc.local
.
Is this really the right way to do this?
Best Answer
You can use
sysctl
to set some of the kernel parameters, specifically the ones under/proc/sys
. These can be set in the file/etc/sysctl.conf
or added to a single file (the preferred method on some distro's such as Fedora) in the directory/etc/sysctl.d
. On distros that have this directory it's meant for customization's.excerpt from sysctl's man page
Example
You can get a partial list of what kernel parameters are currently set using this command:
Making a change
/etc/sysctl.conf
Simply add rules to the file
sysctl.conf
.You can also use the
sysctl.conf
command line to make edits to this file without having to edit it directly.After making any changes be sure to make them active.
/etc/sysctl.d
To add your override of this parameter simply put it in a file named similarly to the files that are already present in the
/etc/sysctl.d
directory.In a file named something like
99-myparam.conf
.Where the name of the parameter is on the left, and it's corresponding value is on the right.
See
sysctl
's man page for more details.