I want to start a systemd service from its D-Bus interface. However, it seems that services that are not already started or "enabled" (running on startup) are unknown to the Systemd D-Bus interface :

# my-service.service
Description=My service


> systemctl status my-service
● my-service.service - My service
     Loaded: loaded (/usr/local/lib/systemd/system/my-service.service; disabled; vendor preset: enabled)
     Active: inactive (dead)

> gdbus call --system --dest org.freedesktop.systemd1 -o /org/freedesktop/systemd1 -m org.freedesktop.systemd1.Manager.GetUnit my-service.service
Erreur : GDBus.Error:org.freedesktop.systemd1.NoSuchUnit: Unit my-service.service not loaded.

> systemctl enable my-service.service
Created symlink /etc/systemd/system/multi-user.target.wants/my-service.service → /usr/local/lib/systemd/system/my-service.service.

> gdbus call --system --dest org.freedesktop.systemd1 -o /org/freedesktop/systemd1 -m org.freedesktop.systemd1.Manager.GetUnit my-service.service
(objectpath '/org/freedesktop/systemd1/unit/my_2dservice_2eservice',)

I can start my-service with systemctl, but I cannot access it via D-Bus. How can I use the D-Bus interface as I can use systemctl, to start disabled services?


According to systemd D-Bus interface documentation, there's the method LoadUnit(name) to get unit information and loading it from disk if not already.

Also it seems that the StartUnit(name, mode) method doesn't seems to indicate if it loads the unit but it would be a reasonable guess it does.

  • I'm not sure why systemctl status says that the service is loaded, it's misleading. But that seems to work. Thanks!
    – Hugal31
    Oct 19 '20 at 8:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.