May 19, 2025

Samba Shares made simple

Configuring SMB (Samba) Shares was always a headache for me, but this time I found the way to make it simpler and painless to configure.

First of all, the requirements:

  1. An Ubuntu or Debian server (or VM) that is going to share a folder over SMB (let's call it host).
  2. A Windows, macOS, or Linux machine that is going to access the SMB folder from the host (let's call it guest).

Configuring the Host

Let's assume that the shared folder is located in /mnt/shared in the host. You can mount another drive on this folder or modify this location if you want. First, we're going to create it (if it doesn't exist) and give all permissions to all users to this folder:

mkdir -p /mnt/shared
chmod 0777 /mnt/shared

Then we're installing Samba on the host:

sudo apt update
sudo apt install samba

Now we make a backup of the current Samba config file and delete it:

sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
sudo rm /etc/samba/smb.conf

Let's recreate the Samba config file:

sudo nano /etc/samba/smb.conf

Copy the following to the new config file:

# /etc/samba/smb.conf

[global]
#to allow symlinks from everywhere
allow insecure wide links = yes 
workgroup = WORKGROUP
dos charset = cp866
unix charset = utf-8
force user = smbuser

[shared]
# to follow symlinks
follow symlinks = yes
# to allow symlinks from outside
wide links = yes
browseable = yes
writeable = yes
path = /mnt/shared

You can add more shared directories by creating new subsections like the shared one. Press Ctrl+O to save in Nano editor and Ctrl+X to exit.

Now create the user that's going to access the Samba share (both as a system user and Samba user). In this case, the user will be smbuser (if you change the name, do not forget to change in the global subsection in smb.conf file). Give both system user and Samba user the same password.

adduser smbuser
smbpasswd -a smbuser

Now restart the SMB daemon:

sudo systemctl restart smbd

In ordert to the Samba share to be visible in Windows, we need to install the WSDD Server first:

sudo apt install wsdd-server

Let's configure the WSDD server:

sudo nano /etc/default/wsdd

Edit the file like this:

#
# Defaults file for wsdd
#
# Useful args here are -i eth0 -6 etc
# Consult wsdd(8) man page
WSDD_PARAMS="--workgroup WORKGROUP"

Now restart WSDD Server:

sudo systemctl restart wsdd-server

Configuring the Guests

The Samba share should be visible from all guests sharing the network with the host, it should appear in the Network options in any OS. In case you're asked for credentials while accessing from the guest, use the ones configured on the Samba user in the host (smbuser in this case).

Hope you like this tutorial!