NAS and Storage

Share files with Samba for Windows, Mac and Linux

With Samba you can turn a regular Linux computer, mini PC, or Raspberry Pi into a file server. Windows, macOS, and Linux can open the folder as if it were a regular disk. This guide works on Debian, Ubuntu, and Raspberry Pi OS.

Step 1: install Samba

sudo apt update
sudo apt install samba

Step 2: create a folder and a group

We’ll create the folder /srv/nas/gedeeld and a group nas. Everyone in that group can write to it.

sudo mkdir -p /srv/nas/gedeeld
sudo groupadd nas
sudo usermod -aG nas $USER
sudo chown -R root:nas /srv/nas/gedeeld
sudo chmod -R 2775 /srv/nas/gedeeld

The number 2775 gives the group write permissions and ensures that new files stay assigned to the same group. An explanation per digit can be found in our chmod calculator.

Step 3: set a password for Samba

Samba has its own password, separate from your login on the server. The user must already exist on the server.

sudo smbpasswd -a $USER

Step 4: add the folder to the configuration

Open the file with sudo nano /etc/samba/smb.conf and add at the bottom:

[gedeeld]
   path = /srv/nas/gedeeld
   browseable = yes
   read only = no
   valid users = @nas
   create mask = 0664
   directory mask = 0775

Check the file for errors and restart Samba:

testparm
sudo systemctl restart smbd

Step 5: connect from your computer

  • Windows: open File Explorer and type in the address bar \\your-server\gedeeld (with the address or name of your server). Choose Map network drive to assign it a drive letter.
  • macOS: in Finder choose Go → Connect to Server (⌘+K) and type smb://your-server/gedeeld.
  • Linux: open your file manager and type smb://your-server/gedeeld.

Log in with the user and password from step 3.

Firewall and security

  • If you use ufw, allow Samba for your own network: sudo ufw allow from 192.168.1.0/24 to any app Samba.
  • Never expose Samba (port 445) to the internet. If you want to access it from outside, use a VPN like WireGuard or Tailscale. See the port list.
  • Only give access to users who need it, and create a separate folder with its own permissions for each person or purpose.

Useful tips

  • With sudo smbstatus you can see who is connected.
  • Make sure your server always has the same IP address, either via a static address or a reservation in your router.
  • Make a backup of the folder. A shared folder is not a backup yet.
Can't do it yourself? Have an expert come to your home via hulpaanhuis.nl