How can I restore a systemd service after editing it using "systemctl edit service"?

If you're running a version of systemd higher than of "229", then you can simply use:

systemctl revert name.service

From github commit:

This allows dropping all user configuration and reverting back to the vendor default of a unit file.

  • It basically undoes what:
    • "systemctl edit"
    • "systemctl set-property" and
    • "systemctl mask" do.

Ubuntu 16.04 uses "systemd version 229", so you should remove override file manually:

sudo rm -r /etc/systemd/system/name.service.d

Then reload systemd daemon and restart your service:

sudo systemctl daemon-reload
sudo systemctl restart name.service

Remember that if you used --full with edit subcommand to copy the original unit instead of creating a drop-in file, then you should remove /etc/systemd/system/name.service instead of the directory.