To make a value survive a reboot, you write it to a file, and the system sets it at every start.
At boot the systemd-sysctl service reads the *.conf files from /etc/sysctl.d, /run/sysctl.d and /usr/lib/sysctl.d and sets the values written there. A file holds lines of the form name = value:
The files are applied in name order across all the directories together. If a parameter appears in two files, the value from the last one stays, which is why file names start with a number. A file with another extension, such as .txt or .bak, is skipped.
To apply the files without a reboot, run sudo sysctl --system. It reads the same directories in the same order and prints every file and every value: the output tells you whether your line reached the kernel.
/etc/sysctl.d/10-watches.conf has fs.inotify.max_user_watches = 65536, and /etc/sysctl.d/90-desktop.conf has fs.inotify.max_user_watches = 16384. What value will the parameter have after a boot?
-
The size of the value does not matter: the files are applied in name order, and 90-desktop.conf comes after 10-watches.conf.
-
There is no dispute: each file simply sets the value, and the last one stays.
sudo sysctl --systemshows both lines in order.
The files are applied in name order, and the last value written stays. 90-desktop.conf comes after 10-watches.conf, so after a boot the value is 16384. The file order is visible in the output of sudo sysctl --system.
Key points
-
sysctl -wchanges a parameter until a reboot; at start the kernel begins with its own values. -
A lasting value is a
name = valueline in a*.conffile in/etc/sysctl.d; at boot systemd-sysctl sets it. -
sudo sysctl --systemapplies the files right away; of two files with the same parameter, the value from the last by name stays.