84 lines
1.3 KiB
Markdown
84 lines
1.3 KiB
Markdown
# Uninstall Samba
|
|
|
|
This recipe completely removes Samba from Ubuntu, including services, packages, and configuration files.
|
|
|
|
## Stop Services
|
|
|
|
```bash
|
|
sudo systemctl stop smbd
|
|
sudo systemctl stop nmbd
|
|
```
|
|
|
|
## Disable Services
|
|
|
|
```bash
|
|
sudo systemctl disable smbd
|
|
sudo systemctl disable nmbd
|
|
```
|
|
|
|
## Remove Packages
|
|
|
|
```bash
|
|
sudo apt purge -y samba samba-common samba-common-bin smbclient
|
|
sudo apt autoremove -y
|
|
```
|
|
|
|
## Remove Configuration
|
|
|
|
```bash
|
|
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:
|
|
|
|
```bash
|
|
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.
|
|
|
|
```bash
|
|
sudo rm -rf /srv/samba
|
|
```
|
|
|
|
## Verify Removal
|
|
|
|
Check that the package is no longer installed.
|
|
|
|
```bash
|
|
dpkg -l | grep samba
|
|
```
|
|
|
|
No packages should be listed.
|
|
|
|
Verify that the service no longer exists.
|
|
|
|
```bash
|
|
systemctl status smbd
|
|
```
|
|
|
|
Expected output:
|
|
|
|
```text
|
|
Unit smbd.service could not be found.
|
|
```
|
|
|
|
Verify that the configuration directory has been removed.
|
|
|
|
```bash
|
|
ls /etc/samba
|
|
```
|
|
|
|
Expected output:
|
|
|
|
```text
|
|
ls: cannot access '/etc/samba': No such file or directory
|
|
```
|