Linux: Samba

By tjohnson , 21 May, 2025

How to Set Up Samba on a Linux Server (Debian, Ubuntu, Bookworm, Bullseye)

This clean step-by-step guide will help you get Samba running on a Linux server. It allows Windows, Mac, or Linux clients to access shared folders over the network.

โœ… Step-by-Step: Install and Configure Samba

๐Ÿ› ๏ธ 1. Install Samba

sudo apt update
sudo apt install samba

๐Ÿ› ๏ธ 2. Create a Folder to Share

sudo mkdir -p /srv/samba/share
sudo chown nobody:nogroup /srv/samba/share
sudo chmod 0775 /srv/samba/share

This creates a public read/write share.

๐Ÿ› ๏ธ 3. Configure the Samba Share

Edit the Samba config file:

sudo nano /etc/samba/smb.conf

Add the following at the bottom of the file:

[PublicShare]
   path = /srv/samba/share
   browsable = yes
   read only = no
   guest ok = yes
   force user = nobody

๐Ÿ› ๏ธ 4. Restart the Samba Service

sudo systemctl restart smbd

Enable it at boot:

sudo systemctl enable smbd

โœ… 5. Access the Share from Other Machines:

  • ๐Ÿ”น Windows:
    Open File Explorer and enter:
    \\192.168.X.X\PublicShare (replace with server IP)
  • ๐Ÿ”น Linux:
    nautilus smb://192.168.X.X/PublicShare
  • ๐Ÿ”น macOS:
    Finder โ†’ Go โ†’ Connect to Server โ†’ smb://192.168.X.X/PublicShare

๐Ÿ” Optional: Create a Private Share (With Username & Password)

1. Create a Samba User and Password:

sudo useradd sambauser
sudo smbpasswd -a sambauser

2. Set Up Folder Permissions:

sudo mkdir -p /srv/samba/private
sudo chown sambauser:sambauser /srv/samba/private
sudo chmod 0700 /srv/samba/private

3. Add This to /etc/samba/smb.conf:

[PrivateShare]
   path = /srv/samba/private
   valid users = sambauser
   read only = no

4. Restart Samba:

sudo systemctl restart smbd

๐Ÿงช Test the Samba Share

smbclient //localhost/PublicShare -N

Or to list shares available to a user:

smbclient -L //localhost -U sambauser