0

How are services installed by the package manager (in /usr/lib/systemd/) supposed to be used in Debian (9.5)?

I can see loads of services installed in /usr/lib/systemd/user, but these are not available via the normal systemctl status my-service command. Am I supposed to manually copy the services I want to use into /etc/systemd/user/?

3

Systemd allows you to have a user-specific services for each user in addition to the system-wide services. Those can be managed by regular systemctl command (stop, start, status, edit, enable, ...) if you add the --user flag. If you have for example /usr/lib/systemd/user/syncthing.service, the system-wide service manager doesn't know about it, but the one for users does:

↪ ls /usr/lib/systemd/user/syncthing.service 
Permissions Size User Date Modified Name
.rw-r--r--   285 root 13 Jun 20:40  /usr/lib/systemd/user/syncthing.service
↪ systemctl status syncthing                                                                                     
Unit syncthing.service could not be found.
↪ systemctl --user status syncthing               
● syncthing.service - Syncthing - Open Source Continuous File Synchronization
   Loaded: loaded (/usr/lib/systemd/user/syncthing.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2018-07-24 17:10:22 CEST; 2 weeks 3 days ago
     Docs: man:syncthing(1)
 Main PID: 815 (syncthing)
   CGroup: /user.slice/user-1000.slice/user@1000.service/syncthing.service
           └─815 /usr/bin/syncthing -no-browser -no-restart -logflags=0

systemctl status --user can be used to list all currently active units for the current user.

It's also possible for users to define their own units if they are unable to write to /usr/lib/systemd/user or for the administrator to define user units local to the system, by adding them to one of the directories listed for this purpose in systemd.unit(5):

  • ~/.config/systemd/user/
  • /etc/systemd/user/
  • $XDG_RUNTIME_DIR/systemd/user/
  • ~/.local/share/systemd/user/
2

Use systemctl --user status my-service for user services. User services are also displayed under the user.slice of systemctl status command. You also need --user flag to start/stop/enable/disable these services since they run under a normal user session and don't require root access. Read more at https://wiki.archlinux.org/index.php/Systemd/User

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.