sysctl.d — Persistent kernel settings
systemd-sysctl reads .conf snippets at boot. Files are ordered by filename across directories; a same-name file in /etc overrides lower-priority vendor copies. Later applicable assignments override earlier ones. procps sysctl --system has its own search order and may also read /etc/sysctl.conf; check which loader the distribution uses. Values and defaults depend on kernel build, namespace and boot configuration. For systemd-sysctl, a key whose first separator is a slash preserves the remaining separators; when the first separator is a dot, slash and dot characters are exchanged to form the procfs path. This matters for interface names containing dots. Explicit assignments take precedence over glob matches. The example reads the kernel release only and models ordering for a fictional key, not an actual setting. Do not use sysctl -p or --system for validation: these write parameters. Before any approved VM change record current values and persistence sources; restore both the prior value and file if needed and verify after reboot.
Formal Syntax & Structure
kernel.PARAMETER = VALUEParameters & Attributes
| Name | Type | Description |
|---|---|---|
| key | directive or field | Supported runtime parameter |
| value | directive or field | Parameter-specific value |
Return Value
Read-only runtime observation and modeled precedence.
Working Example
set -eud=$(mktemp -d)trap 'rm -rf -- "$d"' EXITprintf 'demo.example = 1\n' > "$d/10-vendor.conf"printf 'demo.example = 2\n' > "$d/90-local.conf"awk -F ' = ' '$1=="demo.example" {v=$2} END {print "modeled final value=" v}' "$d/10-vendor.conf" "$d/90-local.conf"test "$(sysctl -n kernel.osrelease)" = "$(uname -r)"printf 'kernel release matches uname\n'