1SYSTEMD.PRESET(5) systemd.preset SYSTEMD.PRESET(5)
2
3
4
6 systemd.preset - Service enablement presets
7
9 /etc/systemd/system-preset/*.preset
10
11 /run/systemd/system-preset/*.preset
12
13 /usr/lib/systemd/system-preset/*.preset
14
15 /etc/systemd/user-preset/*.preset
16
17 /run/systemd/user-preset/*.preset
18
19 /usr/lib/systemd/user-preset/*.preset
20
22 Preset files may be used to encode policy which units shall be enabled
23 by default and which ones shall be disabled. They are read by systemctl
24 preset which uses this information to enable or disable a unit.
25 Depending on that policy, systemctl preset is identical to systemctl
26 enable or systemctl disable. systemctl preset is used by the post
27 install scriptlets of rpm packages (or other OS package formats), to
28 enable/disable specific units by default on package installation,
29 enforcing distribution, spin or administrator preset policy. This
30 allows choosing a certain set of units to be enabled/disabled even
31 before installing the actual package. For more information, see
32 systemctl(1).
33
34 It is not recommended to ship preset files within the respective
35 software packages implementing the units, but rather centralize them in
36 a distribution or spin default policy, which can be amended by
37 administrator policy, see below.
38
39 If no preset files exist, preset operations will enable all units that
40 are installed by default. If this is not desired and all units shall
41 rather be disabled, it is necessary to ship a preset file with a
42 single, catchall "disable *" line. (See example 1, below.)
43
44 When the machine is booted for the first time, systemd(1) will
45 enable/disable all units according to preset policy, similarly to
46 systemctl preset-all. Also see "First Boot Semantics" in machine-id(5).
47
49 The preset files contain a list of directives consisting of either the
50 word "enable" or "disable" followed by a space and a unit name
51 (possibly with shell style wildcards), separated by newlines. Empty
52 lines and lines whose first non-whitespace character is "#" or ";" are
53 ignored. Multiple instance names for unit templates may be specified as
54 a space separated list at the end of the line instead of the customary
55 position between "@" and the unit suffix.
56
57 Presets must refer to the "real" unit file, and not to any aliases. See
58 systemd.unit(5) for a description of unit aliasing.
59
60 Two different directives are understood: "enable" may be used to enable
61 units by default, "disable" to disable units by default.
62
63 If multiple lines apply to a unit name, the first matching one takes
64 precedence over all others.
65
66 Each preset file shall be named in the style of
67 <priority>-<policy-name>.preset. Files in /etc/ override files with the
68 same name in /usr/lib/ and /run/. Files in /run/ override files with
69 the same name in /usr/lib/. Packages should install their preset files
70 in /usr/lib/. Files in /etc/ are reserved for the local administrator,
71 who may use this logic to override the preset files installed by vendor
72 packages. All preset files are sorted by their filename in
73 lexicographic order, regardless of which of the directories they reside
74 in. If multiple files specify the same unit name, the entry in the file
75 with the lexicographically earliest name will be applied. It is
76 recommended to prefix all filenames with a two-digit number and a dash,
77 to simplify the ordering of the files.
78
79 If the administrator wants to disable a preset file supplied by the
80 vendor, the recommended way is to place a symlink to /dev/null in
81 /etc/systemd/system-preset/ bearing the same filename.
82
84 Example 1. Default to off
85
86 # /usr/lib/systemd/system-preset/99-default.preset
87
88 disable *
89
90 This disables all units. Due to the filename prefix "99-", it will be
91 read last and hence can easily be overridden by spin or administrator
92 preset policy.
93
94 Example 2. Enable multiple template instances
95
96 # /usr/lib/systemd/system-preset/80-dirsrv.preset
97
98 enable dirsrv@.service foo bar baz
99
100 This enables all three of dirsrv@foo.service, dirsrv@bar.service and
101 dirsrv@baz.service.
102
103 Example 3. A GNOME spin
104
105 # /usr/lib/systemd/system-preset/50-gnome.preset
106
107 enable gdm.service
108 enable colord.service
109 enable accounts-daemon.service
110 enable avahi-daemon.*
111
112 This enables the three mentioned units, plus all avahi-daemon
113 regardless of which unit type. A file like this could be useful for
114 inclusion in a GNOME spin of a distribution. It will ensure that the
115 units necessary for GNOME are properly enabled as they are installed.
116 It leaves all other units untouched, and subject to other (later)
117 preset files, for example like the one from the first example above.
118
119 Example 4. Administrator policy
120
121 # /etc/systemd/system-preset/00-lennart.preset
122
123 enable httpd.service
124 enable sshd.service
125 enable postfix.service
126 disable *
127
128 This enables three specific services and disables all others. This is
129 useful for administrators to specifically select the units to enable,
130 and disable all others. Due to the filename prefix "00-" it will be
131 read early and override all other preset policy files.
132
134 Different distributions have different policies on which services shall
135 be enabled by default when the package they are shipped in is
136 installed. On Fedora all services stay off by default, so that
137 installing a package will not cause a service to be enabled (with some
138 exceptions). On Debian all services are immediately enabled by default,
139 so that installing a package will cause its services to be enabled
140 right-away.
141
142 Even within a single distribution, different spins (flavours, remixes,
143 whatever you might want to call them) of a distribution also have
144 different policies on what services to enable, and what services to
145 leave off. For example, Fedora Workstation will enable gdm as display
146 manager by default, while the Fedora KDE spin will enable sddm instead.
147
148 Different sites might also have different policies what to turn on by
149 default and what to turn off. For example, one administrator would
150 prefer to enforce the policy of "sshd should be always on, but
151 everything else off", while another one might say "snmpd always on, and
152 for everything else use the distribution policy defaults".
153
154 Traditionally, policy about which services shall be enabled were
155 implemented in each package individually. This made it cumbersome to
156 implement different policies per spin or per site, or to create
157 software packages that do the right thing on more than one
158 distribution. The enablement mechanism was also encoding the enablement
159 policy.
160
161 The preset mechanism allows clean separation of the enablement
162 mechanism (inside the package scriptlets, by invoking systemctl preset)
163 and enablement policy (centralized in the preset files), and lifts the
164 configuration out of individual packages. Preset files may be written
165 for specific distributions, for specific spins or for specific sites,
166 in order to enforce different policies as needed. It is recommended to
167 apply the policy encoded in preset files in package installation
168 scriptlets.
169
171 systemd(1), systemctl(1), systemd-delta(1)
172
173 daemon(7) has a discussion of packaging scriptlets.
174
175 Fedora page introducing the use of presets: Features/PackagePresets[1].
176
178 1. Features/PackagePresets
179 https://fedoraproject.org/wiki/Features/PackagePresets
180
181
182
183systemd 253 SYSTEMD.PRESET(5)