Ubuntu - SystemD - Custom Configuration for Template Systemd Service

A template systemd service contains the @ symbol like the Syncthing service.

/lib/systemd/system/syncthing@.service

NOTE: This kind of service allows you to run multiple instances.

  • For example, you can run Syncthing for two users with:
    sudo systemctl start syncthing@user1.service
    sudo systemctl start syncthing@user2.service

Add custom configuration to this kind of service

Create a folder for each of these services.

sudo mkdir -p /etc/systemd/system/syncthing@user1.service.d
sudo mkdir -p /etc/systemd/system/syncthing@user2.service.d

Create the custom configuration file.

sudo vi /etc/systemd/system/syncthing@user1.service.d/custom.conf
sudo vi /etc/systemd/system/syncthing@user2.service.d/custom.conf

Reload systemd.

sudo systemctl daemon-reload