Samba (SMB) Share Setup

Dec 4th 2026 — linux, samba, smb, nas, storage, server

Install Samba

This page explains how to set up a password-protected Samba share on Linux without guest access.

sudo apt-get update
sudo apt-get install samba

Create Share Directory & Set Permissions

Create the folder you want to share and assign ownership to your user:

sudo mkdir -p /mnt/share
sudo chown -R <username>:<username> /mnt/share
sudo chmod -R 770 /mnt/share

Create Samba User

Add an existing Linux user to Samba and set a password for SMB login:

sudo smbpasswd -a <username>

Configure smb.conf

Edit the Samba configuration file:

sudo nano /etc/samba/smb.conf

Add the following block at the bottom of the file:

[MyShare]
   path = /mnt/share
   valid users = <username>
   browseable = yes
   writable = yes
   read only = no
   guest ok = no
   create mask = 0660
   directory mask = 0770

📌 Note: guest ok = no ensures nobody on the network can access the folder without valid credentials.

Test & Restart Samba

Check for syntax errors, restart the service, and allow Samba through UFW if enabled:

testparm
sudo systemctl restart smbd
sudo ufw allow samba