How to Restart Samba Service After Configuration Changes for Immediate Effect


4 views

After modifying /etc/samba/smb.conf, you might notice your changes aren't being reflected. This is completely normal - Samba needs to reload its configuration. Unlike some services that auto-detect config changes, Samba requires explicit service restart.

The exact command depends on your init system:

systemd (Most modern Linux distros):

sudo systemctl restart smbd
sudo systemctl restart nmbd  # If using NetBIOS

SysVinit (Older systems):

sudo service smbd restart
sudo service nmbd restart

Check status with:

sudo systemctl status smbd
# Or alternatively:
smbstatus

For minor changes, you might try reloading instead of full restart:

sudo systemctl reload smbd

Always test your config first to avoid service failure:

testparm

For development environments, consider setting up automatic reloads:

#!/bin/bash
inotifywait -m -e modify /etc/samba/smb.conf |
while read; do
    systemctl reload smbd
done

You've edited /etc/samba/smb.conf but your changes aren't visible? This is a common scenario when working with Samba file sharing. Unlike some services that automatically reload configurations, Samba requires explicit service restart after configuration modifications.

The exact command depends on your Linux distribution's init system:

# Systemd (Ubuntu 16.04+, Debian 8+, CentOS 7+)
sudo systemctl restart smbd nmbd
# OR combined in newer versions
sudo systemctl restart smb

# SysVinit (Older systems)
sudo service smbd restart
sudo service nmbd restart
# OR
sudo /etc/init.d/samba restart

Check service status to confirm:

systemctl status smb
# Should show "active (running)" and recent restart time

For minor changes, you might try reloading instead of full restart:

sudo systemctl reload smb

Note: Reload maintains existing connections while applying new configs, but some changes (like share definitions) require full restart.

If changes still don't appear after restart:

# Test config file syntax
testparm

# Check logs for errors
journalctl -u smb -n 50 --no-pager
# OR
tail -n 50 /var/log/samba/log.smbd

For development environments, you can automate this with inotify:

#!/bin/bash
while inotifywait -e close_write /etc/samba/smb.conf; do
  systemctl restart smb
done