systemd-update-helper — Enable, disable, stop, and restart units when packages are installed, upgraded, or removed
/usr/lib/systemd/systemd-update-helper [OPTIONS...] {COMMAND} [UNIT...]
Package managers call systemd-update-helper from the scriptlets of packages that contain unit files. The systemd RPM macros and file triggers call it. It has to run as root.
By default, the commands operate on the system service manager and the system unit directories.
With --global, they operate on the global user unit configuration and on every running
user service manager, i.e. every active user@
unit. A user service manager that fails or does not finish the operation within 15 seconds is skipped
and does not affect the others. The timeout is set at build time with the
UID.service-Dupdate-helper-user-timeout-sec= option.
If the system was not booted with systemd, or the helper runs in a
chroot(2)
environment, the commands only change unit files and skip all operations on service managers. Set
$SYSTEMD_OFFLINE= to override this detection, see
Known Environment Variables.
A UNIT argument is either a unit name or the absolute path of a unit
file directly in /usr/lib/systemd/system/ or /etc/systemd/system/,
or in /usr/lib/systemd/user/ or /etc/systemd/user/ with
--global. The path does not have to exist. Template units passed to
remove-units, mark-restart-units, and
mark-reload-units apply to all active instances of the template.
install-units UNIT…¶Enables or disables the units according to the preset policy, like
systemctl preset does. With --global, applies the user preset
policy to the global user unit configuration, like systemctl --global preset
does.
remove-units UNIT…¶Disables the units and stops them. With --global, each running user
service manager also disables the units in the configuration of its user, where
systemctl --user enable creates its symlinks.
mark-restart-units UNIT…, mark-reload-units UNIT…¶Marks the units to be restarted or reloaded by the next enqueue-marked. See enqueue-marked in systemctl(1).
daemon-reload¶Reloads the configuration of the service manager. With --global,
reloads every running user service manager.
enqueue-marked¶Restarts or reloads the units that are marked for it, and waits for the jobs to finish.
daemon-reload-enqueue-marked¶Runs daemon-reload, then enqueue-marked.
--system¶Operates on the system service manager and the system unit directories. This is the default.
--global¶Operates on the global user unit configuration and on every running user service manager.
--stdin¶Reads the units from standard input, one unit name or unit file path per line, instead of from the arguments. Lines that do not name a unit, or name a path outside of the unit directories, are ignored. The RPM file triggers pass the unit files of removed packages this way.
--dry-run¶Logs the changes and operations without performing them.
-q, --quiet¶Only logs errors.
-h, --help¶--version¶Print a short version string and exit.
On success, 0 is returned, a non-zero failure code otherwise. A failure to preset a unit with install-units makes the command fail. Failures to disable, stop, mark, restart, or reload individual units, and failures of individual user service managers, are logged and do not change the exit status.
Example 1. Disable and stop the units of a removed package
# printf '%s\n' /usr/lib/systemd/system/sshd.service /usr/lib/systemd/system/sshd@.service | \
/usr/lib/systemd/systemd-update-helper --stdin remove-unitsThis disables sshd.service and sshd@.service, and stops
sshd.service and all active instances of sshd@.service.