Step 1: Install Samba
sudo apt update
sudo apt install samba -y
Check Samba version:
smbd --version
Step 2: Create Share Folder
sudo mkdir -p /srv/samba/share
Set permissions (for testing, full access):
sudo chmod 0777 /srv/samba/share
In production, use proper ACLs instead of 0777.
Step 3: Create Samba User
Samba user must exist on the system:
sudo useradd sambauser
sudo passwd sambauser
Add user to Samba:
sudo smbpasswd -a sambauser
sudo smbpasswd -e sambauser
Step 4: Configure Samba
Edit config file:
sudo nano /etc/samba/smb.conf
Add at the end:
[Share]
path = /srv/samba/share
browsable = yes
writable = yes
guest ok = no
read only = no
force user = sambauser
Step 5: Check Configuration
testparm
Fix errors if any.
Step 6: Restart Samba
sudo systemctl restart smbd nmbd
sudo systemctl enable smbd nmbd
Step 7: Configure Firewall (if UFW is enabled)
sudo ufw allow samba
Step 8: Connect from Windows
- Press
Win + R. - Enter:
\\<server_ip>\Share
- Use Samba username/password.
Step 9: Troubleshooting
- Check logs:
journalctl -xeu smbd
- Validate config:
testparm
- Test share availability:
smbclient -L localhost -U sambauser