DH_INSTALLSYSTEMD(1)
π DH_INSTALLSYSTEMD π
okay bestie, so this is a page from the Debhelper manual set, and it's literally the one that handles your systemd unit files. sit with me, we're gonna get through it together π«Ά
β¨ NAME β¨
dh_installsystemd β install systemd unit files π
πΈ SYNOPSIS πΈ
dh_installsystemd [debhelper options] [--restart-after-upgrade]
[--no-stop-on-upgrade] [--no-enable] [--no-start] [--name=name]
[unit file ...]
π¦ DESCRIPTION π¦
So dh_installsystemd is a debhelper program, and its whole job, its entire purpose, its main character era, is installing the systemd unit files that the package maintainer supplied. π
But wait, there's more (there's always more, iykyk). It also goes and finds the service files that a package installed, and it generates preinst, postinst, and prerm code blocks for enabling, disabling, starting, stopping, and restarting the matching systemd services whenever the package gets installed, updated, or removed. Those little snippets get added into your maintainer scripts by dh_installdeb(1). β¨
Now, deb-systemd-helper(1) is what actually does the enabling and disabling of systemd units. Which means β and this is the iconic part β the machine does not have to actually be running systemd at package installation time. Enabling happens on every machine, so you can switch from sysvinit to systemd and back again. no cap. π₯
And here's how it decides what to touch: dh_installsystemd operates on all unit files installed by a package. If you only want blocks generated for specific unit files, just pass them as arguments, like "dh_installsystemd quota.service". And if you wanna exclude specific unit files from processing, that's what the -X common debhelper(1) option is for. π
π FILES π
debian/package.mount,debian/package.path,debian/package@.path,debian/package.service,debian/package@.service,debian/package.socket,debian/package@.socket,debian/package.target,debian/package@.target,debian/package.timer,debian/package@.timerβ if any of these exist, they get installed intousr/lib/systemd/system/in the package build directory. πdebian/package.tmpfileβ okay so this one is only used in compat 12 or earlier. In compat 13 and up, this file is handled bydh_installtmpfiles(1)instead, so it's not your girl anymore.
If it does exist, it's installed into usr/lib/tmpfiles.d/ in the package build directory. β¨
π OPTIONS π
-n,--no-scriptsβ do not modifypostinst/postrm/prermscripts.
heads up: this option was silently ignored before debhelper/13.24. so if you were relying on it in an older version... yeah, it just did nothing. π
--no-enableβ disables the service(s) on purge, but does not enable them on install.
note that this does not affect whether the services are started. so please, please remember to also use --no-start if the service shouldn't be started. don't be out here catching strays from your own flags π
--name=nameβ this option controls several things, she's got range.
It changes the name that dh_installsystemd uses when looking for maintainer-provided systemd unit files, as listed in the "FILES" section. Example time: dh_installsystemd --name foo will look for debian/package.foo.service instead of debian/package.service. Those unit files get installed as name.unit-extension β so in that example, it would be installed as foo.service. β
AND, if no unit files are passed explicitly as command line arguments, dh_installsystemd will only act on unit files called name β rather than all the unit files found in the package. slay.
--restart-after-upgradeβ do not stop the unit file until after the package upgrade has been completed. This is the default behaviour in compat 10. π
In earlier compat levels, the default was to stop the unit file in the prerm, and start it again in the postinst.
This can be useful for daemons that shouldn't have a possibly long downtime during upgrade. But β and this is a big but β you should make sure that the daemon won't get confused by the package being upgraded while it's running before you use this option. π«Ά
--no-restart-after-upgradeβ undoes a previous--restart-after-upgrade(or the default of compat 10). If no other options are given, this will cause the service to be stopped in theprermscript and started again in thepostinstscript. π«-r,--no-stop-on-upgrade,--no-restart-on-upgradeβ do not stop the service on upgrade. This has the side-effect of not restarting the service as part of the upgrade.
If you want to restart the service with minimal downtime, please use --restart-after-upgrade (default in compat 10 or later). If you want the service restarted but also stopped during the upgrade, then please use --no-restart-after-upgrade β note the "after-upgrade". that word is doing so much heavy lifting bestie π
note that the--no-restart-on-upgradealias is deprecated and will be removed in compat 14. This is to avoid confusion with the--no-restart-after-upgradeoption. rip to a real one π
--no-startβ do not start the unit file after upgrades, and after initial installation (that last bit is only relevant for services without a corresponding init script).
note that this option does not affect whether the services are enabled. please remember to also use--no-enableif the services should not be enabled. yes this is the mirror image of the--no-enablewarning. they're a matching set, they're soulmates π
unit file ...β only process and generate maintscripts for the installed unit files with the (base)name unit file.
note:dh_installsystemdwill still install unit files fromdebian/, but it will not generate any maintscripts for them unless they are explicitly listed in unit file ... so don't be surprised when the files show up anyway. that's just how she is. π
π NOTES π
This command is not idempotent. dh_prep(1) should be called between invocations of this command (with the same arguments). Otherwise, it may cause multiple instances of the same text to be added to maintainer scripts. and like, duplicated maintainer script text is not the vibe, we don't want that βπ
π SEE ALSO π
debhelper(7), dh_installinit(1), deb-systemd-helper(1)
π AUTHORS π
pkg-systemd-maintainers@lists.alioth.debian.org
aaaand that's the whole page bestie, you ate that π go forth and install your unit files with confidence. this was 14.5ubuntu1, dated 2026-09-21 β mwah, kiss kiss, see you in the next manpage πβ¨π
π¦ where this page comes from
- ubuntu stonking: debhelper 14.5ubuntu1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms