I don’t think there is any such official documentation.
sysctl entries are handled by
procps and systemd; but neither projects’ documentation address how entries are processed within the same configuration file.
The short version is that the last entry in
sysctl.conf wins, even when other files are present (in
/etc/sysctl.d or elsewhere), regardless of which system is used to load the settings.
To understand how
procps processes entries, we need to look at the source code for
sysctl. This shows that later entries are processed without knowledge of earlier entries, so the last one wins (look at the
Preload function). When multiple configuration files are given on the command line, these are processed in order, as described in the man page:
Using this option
will mean arguments to
sysctl are files, which are read in the
order they are specified.
Things get a little more complex with the
--system option, but at least that’s documented:
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
The documentation isn’t quite complete. As mentioned above, entries within a given file are applied in order, and overwrite any value given to the same setting previously. In addition, looking at the
PreloadSystem function show that files are processed in name order, and that
/etc/sysctl.conf is processed unconditionnally (i.e. an identically-named file in an earlier directory doesn’t override it).
systemd has its own
sysctl handler, which is documented in the
sysctl.d manpage; that has a section on precedence:
Configuration files are read from directories in
/usr/lib/, in order of precedence. Each configuration file in these configuration directories shall be named in the style of
.conf. Files in
/etc/ override files with the same name in
/usr/lib/. Files in
/run/ override files with the same name in
[…] All configuration files are sorted by their filename in lexicographic order, regardless of which of the directories they reside in. If multiple files specify the same option, the entry in the file with the lexicographically latest name will take precedence. It is recommended to prefix all filenames with a two-digit number and a dash, to simplify the ordering of the files.
Again, later entries within a single configuration file override earlier entries.