Creating a User-Based systemd Service

In addition to the system-wide systemd files, systemd enables you to create user-based services that you can run from a user level without requiring root access and privileges. These user-based services are under user control and are configurable independent of system services.

The following are some distinguishing features of user-based systemd services:

  • User-based systemd services are linked with a specific user account.
  • They're created under the associated user’s home directory in $HOME/.config/systemd/user/.
  • After these services are enabled, they start when the associated user logs in. This behavior differs from that of enabled systemd services which start when the system boots.

To create a user based service:

  1. Create the service's unit file in the $HOME/.config/systemd/user directory, for example:
    touch $HOME/.config/systemd/user/myservice.service
  2. Open the unit file and specify the values to the options you want to use, such as Description, ExecStart, WantedBy, and so on.
    For reference, see Configurable Options in Service Unit Files and the systemd.service(5) and systemd.unit(5) manual pages.
  3. Enable the service to start automatically when you log in.
    systemctl --user enable myservice.service

    Note:

    When you log out, the service is stopped unless the root user has enabled processes to continue to run for the user.

    See for more information.

  4. Start the service.
    systemctl --user start myservice.service
  5. Verify that the service is running.
    systemctl --user status myservice.service