117

When I try to restart Samba, I am receiving the following error message:

Failed to start samba.service: Unit samba.service is masked.

In addition, when I run systemctl, it shows smbd.service in red showing failed.

At the same time restart began to fail, I have lost the share ability in folders created and cannot access. Any help would be appreciated!!!

4 Answers4

167

Debian and debian-derivatives changed the service name from 'samba' to 'smbd'.

Try service smbd restart.

GDorn
  • 1,764
  • 1
    anyone know why? – Ben Creasy Aug 12 '17 at 19:28
  • 4
    @BenCreasy probably because the protocol's name is smb, and since this is a daemon, you get smbd. Samba is the name of one of the implementations of the smb protocol. – terdon Nov 06 '17 at 11:22
  • Job for smbd.service failed because the control process exited with error code. See "systemctl status smbd.service" and "journalctl -xe" for details. – M at Feb 26 '18 at 09:38
  • 1
    @M-at That generally means there's an error in your config file. The things it is suggesting you look at will spell that out further. – GDorn Dec 16 '20 at 01:20
48

Try:

sudo systemctl unmask samba
sudo systemctl enable samba
sudo systemctl restart samba
  • 8
    http://unix.stackexchange.com/questions/303293/ubuntu-service-samba-is-masked-and-cant-start – Elder Geek Dec 13 '16 at 15:10
  • 4
    This worked for me with a similar problem with mongodb on Ubuntu 16 after upgrading from 14. I changed the first line, though, to systemctl unmask mongodb.service. After doing this, service mongodb status/start/stop works. – Sevak Avakians Apr 17 '17 at 19:21
  • Failed to restart samba.service: Unit samba.service is masked. – M at Feb 26 '18 at 09:38
  • This seemed to work at first: smbd restarted properly, no logs or errors, but it was still impossible to connect to samba from another machine. The only thing that worked at the end was to uninstall and reinstall samba – amine Apr 10 '19 at 12:28
  • same problem as the guy above, only this one solved here – Murilo Melo Feb 04 '20 at 21:00
  • Thanks! This answer worked for me with php7.4-fpm on Ubuntu 20.04. – Matthew Setter Jun 17 '20 at 13:19
  • What is masking? And should it be re-masked? – KolonUK Aug 20 '21 at 11:35
5

This works for me(Ubuntu server 16):

sudo rm /lib/systemd/system/samba.service 
sudo systemctl enable samba.service nmbd.service
sudo systemctl start samba

Found it from here

Fangxing
  • 271
  • I had the same errors as the OP while running Ubuntu 16.04.5 LTS. This solution fixed the issue for me. – kneeki Sep 27 '18 at 23:41
  • ouch ls -l /lib/systemd/system/samba.service lrwxrwxrwx 1 root root 9 Mar 5 2018 /lib/systemd/system/samba.service -> /dev/null – BozoJoe Nov 05 '18 at 04:24
3

I had the same problem for no apparent reason. Checking the logs I saw that Samba had problems with cached files (improper permissions). rm -R /var/cache/samba/* did the trick.

Tox
  • 131
  • Job for smbd.service failed because the control process exited with error code. See "systemctl status smbd.service" and "journalctl -xe" for details. – M at Feb 26 '18 at 09:39