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