Systemd/User Services: Difference between revisions

show how to enable a service for only specific users
Pigs (talk | contribs)
Add usage section
 
Line 54: Line 54:
};
};
</syntaxhighlight>
</syntaxhighlight>
Likewise, you can also disable a service for a specific user:
<syntaxhighlight lang="nix">
systemd.user.services.my-cool-user-service = {
  unitConfig.ConditionUser = "!root";
};
</syntaxhighlight>
== Usage ==
To interact with user-specific systemd services, use the <code>--user</code> flag with the <code>systemctl</code> command. For example, to check the status of a user service:
<syntaxhighlight lang="console"> $ systemctl --user status my-cool-user-service </syntaxhighlight>
To view logs for a specific user service, use <code>journalctl</code> with the <code>--user-unit</code> option:
<syntaxhighlight lang="console"> $ journalctl --user-unit my-cool-user-service </syntaxhighlight>
To list all active user units:
<syntaxhighlight lang="console"> $ systemctl --user list-units </syntaxhighlight>
[[Category:systemd]]
[[Category:systemd]]