From 988715b43373d7383c0497cc2f6dfb33f7f60a08 Mon Sep 17 00:00:00 2001 From: Jota Odiceu Date: Sat, 4 Jul 2026 15:33:16 -0300 Subject: [PATCH] docs(samba): add install, configure, and uninstall recipes --- recipes/samba/01_install-samba.md | 96 +++++++++++++++++++++++++++++ recipes/samba/02_configure-share.md | 89 ++++++++++++++++++++++++++ recipes/samba/03_uninstall-samba.md | 83 +++++++++++++++++++++++++ 3 files changed, 268 insertions(+) create mode 100644 recipes/samba/01_install-samba.md create mode 100644 recipes/samba/02_configure-share.md create mode 100644 recipes/samba/03_uninstall-samba.md diff --git a/recipes/samba/01_install-samba.md b/recipes/samba/01_install-samba.md new file mode 100644 index 0000000..17a9cc2 --- /dev/null +++ b/recipes/samba/01_install-samba.md @@ -0,0 +1,96 @@ +# Install Samba + +This recipe installs Samba on Ubuntu, enables the required services, and configures a basic file share. + +## Install Packages + +```bash +sudo apt update +sudo apt install -y samba +``` + +## Verify Installation + +```bash +smbd --version +``` + +Expected output: + +```text +Version 4.x.x +``` + +## Enable Services + +```bash +sudo systemctl enable smbd +sudo systemctl enable nmbd +sudo systemctl start smbd +sudo systemctl start nmbd +``` + +## Verify Services + +```bash +systemctl status smbd --no-pager +systemctl status nmbd --no-pager +``` + +Both services should be reported as **active (running)**. + +## Configure Samba + +Replace the default configuration. + +```bash +sudo cp smb.conf /etc/samba/smb.conf +``` + +Validate the configuration. + +```bash +testparm +``` + +Expected output: + +```text +Loaded services file OK. +``` + +## Restart Samba + +```bash +sudo systemctl restart smbd +sudo systemctl restart nmbd +``` + +## Configure Firewall (Optional) + +If UFW is enabled: + +```bash +sudo ufw allow samba +``` + +## Verify Listening Ports + +```bash +sudo ss -tulpn | grep smb +``` + +Expected output should include ports **139** and **445**. + +## Create Samba User (Optional) + +```bash +sudo smbpasswd -a +sudo smbpasswd -e +``` + +List configured Samba users. + +```bash +sudo pdbedit -L +``` diff --git a/recipes/samba/02_configure-share.md b/recipes/samba/02_configure-share.md new file mode 100644 index 0000000..8f904fd --- /dev/null +++ b/recipes/samba/02_configure-share.md @@ -0,0 +1,89 @@ +# Configure Samba Share + +This recipe configures a basic Samba file share. + +## Backup Existing Configuration + +```bash +sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak +``` + +## Create Configuration + +Replace the existing configuration. + +```bash +sudo tee /etc/samba/smb.conf >/dev/null <<'EOF' +[global] + workgroup = WORKGROUP + server string = Samba Server + security = user + map to guest = Bad User + +[Share] + path = /srv/samba + browseable = yes + writable = yes + guest ok = no + read only = no + create mask = 0664 + directory mask = 0775 +EOF +``` + +## Create Share Directory + +```bash +sudo mkdir -p /srv/samba +``` + +## Configure Permissions + +Replace `` with your Linux username. + +```bash +sudo chown -R : /srv/samba +sudo chmod -R 775 /srv/samba +``` + +## Create Samba User + +If the user does not already exist on Linux, create it first. + +```bash +sudo smbpasswd -a +sudo smbpasswd -e +``` + +## Validate Configuration + +```bash +testparm +``` + +Expected output: + +```text +Loaded services file OK. +``` + +## Restart Samba + +```bash +sudo systemctl restart smbd +sudo systemctl restart nmbd +``` + +## Verify Share + +```bash +smbclient -L localhost -U +``` + +Expected output should include: + +```text +Sharename Type +--------- ---- +Share Disk +``` diff --git a/recipes/samba/03_uninstall-samba.md b/recipes/samba/03_uninstall-samba.md new file mode 100644 index 0000000..7afdbf7 --- /dev/null +++ b/recipes/samba/03_uninstall-samba.md @@ -0,0 +1,83 @@ +# 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 +```