Files
.profile/recipes/samba/03_uninstall-samba.md

1.3 KiB

Uninstall Samba

This recipe completely removes Samba from Ubuntu, including services, packages, and configuration files.

Stop Services

sudo systemctl stop smbd
sudo systemctl stop nmbd

Disable Services

sudo systemctl disable smbd
sudo systemctl disable nmbd

Remove Packages

sudo apt purge -y samba samba-common samba-common-bin smbclient
sudo apt autoremove -y

Remove Configuration

sudo rm -rf /etc/samba
sudo rm -rf /var/lib/samba
sudo rm -rf /var/cache/samba
sudo rm -rf /var/log/samba

Remove Firewall Rule (Optional)

If UFW was configured:

sudo ufw delete allow samba

Remove Shared Directories (Optional)

Only run this if the directory was created exclusively for Samba and does not contain important files.

sudo rm -rf /srv/samba

Verify Removal

Check that the package is no longer installed.

dpkg -l | grep samba

No packages should be listed.

Verify that the service no longer exists.

systemctl status smbd

Expected output:

Unit smbd.service could not be found.

Verify that the configuration directory has been removed.

ls /etc/samba

Expected output:

ls: cannot access '/etc/samba': No such file or directory