I need to know if all distributions of Linux have sysctl.conf be under /etc/sysctl.conf
I was told that Arch Linux does not. Can configurations set under the aforementioned path be overridden by another file in some distros?
From man sysctl.conf:
/etc/sysctl.d/*.conf
/run/sysctl.d/*.conf
/usr/local/lib/sysctl.d/*.conf
/usr/lib/sysctl.d/*.conf
/lib/sysctl.d/*.conf
/etc/sysctl.conf
The paths where sysctl preload files usually exist. See also sysctl
option --system.
From man sysctl:
--system
Load settings from all system configuration files. Files are
read from directories in the following list in given order
from top to bottom. Once a file of a given filename is
loaded, any file of the same name in subsequent directories is
ignored.
/etc/sysctl.d/*.conf
/run/sysctl.d/*.conf
/usr/local/lib/sysctl.d/*.conf
/usr/lib/sysctl.d/*.conf
/lib/sysctl.d/*.conf
/etc/sysctl.conf
On modern systems sysctl
configuration is loaded on startup with systemd-sysctl.service
. From man systemd-sysctl:
systemd-sysctl.service is an early boot service that configures sysctl(8) kernel parameters by invoking
/usr/lib/systemd/systemd-sysctl.
When invoked with no arguments, /usr/lib/systemd/systemd-sysctl applies all directives from configuration files listed in
sysctl.d(5).
From what I understand the files are loaded from top to bottom, so configurations stored in /etc/sysctl.conf
might overwrite configurations set earlier.
Pro tip: /usr/lib/systemd/systemd-sysctl --cat-config
Any distribution and vendor and package managers and others who have distribute files may store configurations in any of those directories. Packages will store config in /usr/lib/sysctl.d/*.conf
. Typically the /etc/sysctl.conf
and /etc/sysctl.d/*.conf
are left solely for manual administrator work.
Not always. RHEL8 has a dummy file quoting the man page of
sysctl.d
.man sysctl.d
can read quite a few places.A run of
sysctl --system
on a RHEL8 from the box evaluates files in this order: