How to fix Failed to restart samba.service: Unit samba.service not found on Debian & Ubuntu

Problem:

When trying to restart the Samba service on Ubuntu or Debian using

sudo systemctl restart samba

you see this error message:

Failed to restart samba.service: Unit samba.service not found.

Solution

The samba service is called smbd, not samba. Restart it using

sudo systemctl restart smbd