Welcome to our guide on how to install and configure Samba Share on a Debian 10 server (Buster) & Ubuntu 20.04/18.04 Linux system. Samba is an open-source implementation of the Server Message Block (SMB) and Common Internet File System (CIFS) protocols that provides file and print services between clients across various operating systems.

By configuring Samba server share on Debian 10 (Buster) / Ubuntu 18.04, you can easily share folders or files between Windows and Linux operating systems. In this context, the Windows machine will be used as a client to access Samba share on Linux (Debian 10/Ubuntu 18.04).

Step 1: Install Samba Server on Debian 10 / Ubuntu 20.04/18.04 LTS

To install Samba on Debian 10 Buster / Ubuntu 20.04/18.04, use the commands:

sudo apt -y update
sudo apt -y install samba

If you’re using static IP address, answer no when asked to use WINS settings from DHCP.

install samba debian 01

Once the package is installed, proceed to step 2 where we will do the configuration and manage Samba service.

Step 2: Configure Samba Share on Debian 10 Buster / Ubuntu 20.04/18.04

Samba uses configuration file in /etc/samba/smb.conf. If you change this configuration file, the changes do not take effect until you restart the Samba daemon.

Let’s start by creating a directory to share via Samba. The directory must exist before it can be configured in smb.conf. We will create one under /home.

sudo mkdir -p /home/share

Access to All without Authentication (Not recommended)

The directory should be readable and writable for all users.

sudo chmod 777 /home/share 

Configure Samba share on /etc/samba/smb.conf file.

$ sudo vim /etc/samba/smb.conf


# Configure correct UTP
  unix charset = UTF-8
# Change this to the workgroup/NT-domain name your Samba server will be part of
   workgroup = WORKGROUP
   interfaces = eth0
   bind interfaces only = yes

# Set share configuration at the end
   path = /home/share
   writable = yes
   guest ok = yes
   guest only = yes
   create mode = 0777
   directory mode = 0777

Configuration details:

  • Docs – Samba share name
  • path = /home/share – Directory to share
  • guest ok = yes – Turn on guest share
  • guest only = yes – All protected as guests
  • writable = yes – Set share directory as writable
  • create mode = 0777 & directory mode = 0777 – Allow access to all

Configure Secure Samba Share (Recommended)

Set group ownership of Samba share directory to sambashare group.

sudo chgrp sambashare /home/share

Create samba share users. Replace user1 with samba share user to create.

sudo useradd -M -d /home/share/user1 -s /usr/sbin/nologin -G sambashare user1
sudo mkdir /home/share/user1
sudo chown user1:sambashare /home/share/user1
sudo chmod 2770 /home/share/user1

Set the user password and confirm.

$ sudo smbpasswd -a user1
New SMB password:
Retype new SMB password:
Added user user1.

Enable samba account after setting the password using the command:

$ sudo smbpasswd -e user1
Enabled user user1.

We created a user’s home directory inside Samba share parent directory and set ownership to the samba share group. Let’s create another user.

sudo useradd -M -d /home/share/smbadmin -s /usr/sbin/nologin -G sambashare smbadmin
sudo mkdir /home/share/smbadmin
sudo smbpasswd -a smbadmin
sudo smbpasswd -e smbadmin
sudo chown smbadmin:sambashare /home/share/smbadmin
sudo chmod 2770 /home/share/smbadmin

Configure Secure Samba share.

    path = /home/share/user1
    read only = no
    browseable = no
    force create mode = 0660
    force directory mode = 2770
    valid users = @user1 @sambashare

    path = /home/share/smbadmin
    read only = no
    browseable = yes
    force create mode = 0660
    force directory mode = 2770
    valid users = @sambashare @smbadmin

Restart samba daemon after making the changes.

sudo systemctl restart smbd nmbd

Confirm that the service is running.

install samba debian 02

If you have an active firewall, run:

sudo ufw allow 'Samba'

Step 3: Configure Samba Clients

To access a Samba share on the Linux system, you need to install and configure Samba client.

---------- Install Samba client on Ubuntu / Debian ----
$ sudo apt -y install smbclient cifs-utils

---------- Install Samba client on CentOS / RHEL / Fedora ----
$ sudo yum -y install samba-client cifs-utils
$ sudo dnf -y install samba-client cifs-utils

Accessing Samba share – Temporarily

$ smbclient //sambaserver/share -U sambausername


$ smbclient // -U user1
WARNING: The "syslog" option is deprecated
Enter WORKGROUP\user1's password: 
Try "help" to get a list of possible commands.
smb: \> list
0: server=, share=user1
smb: > ls
   .                                   D        0  Sun Jul 14 01:10:39 2019
   ..                                  D        0  Sun Jul 14 00:49:13 2019
   latest.zip                          N 12121295  Tue Jun 18 10:52:03 2019
     9544896 blocks of size 1024. 7918732 blocks available
 smb: > pwd
 Current directory is \\user1\

You can mount a samba share to a directory in your local Linux system using the mount and cifs type option.

$ mkdir -p ~/mounts/shares
$ mount -t cifs -o username=user1 // ~/mounts/shares
$ df -h
Filesystem              Size  Used Avail Use% Mounted on
/dev/vda1                40G  2.9G   38G   8% /
devtmpfs                488M     0  488M   0% /dev
tmpfs                   496M     0  496M   0% /dev/shm
tmpfs                   496M  6.7M  489M   2% /run
tmpfs                   496M     0  496M   0% /sys/fs/cgroup
tmpfs                   100M     0  100M   0% /run/user/1000
//  9.2G  1.6G  7.6G  18% /home/computingforgeeks/mounts/shares

Mount Samba share using fstab.

You can use fstab file to persist Samba shares mounting through system reboots. In my example, I have the following line added to the end of /ect/fstab file.

//  /mnt/shares cifs credentials=/.sambacreds 0 0

Then I created a credentials file.

$ cat /.sambacreds


$ sudo mkdir -p /mnt/shares
$ sudo mount -a
$ df -hT | grep cifs
// cifs      9.2G  1.6G  7.6G  18% /mnt/shares

For Windows Desktop machines, follow the standard process of mounting a Samba share on Windows. That’s all on how to Install and Configure Samba on Debian 10 / Ubuntu 18.04.

Similar articles:

Install and Configure NFS Server on CentOS 8 / RHEL 8

Best Storage Solutions for Kubernetes & Docker Containers

Stratis Storage Management Cheatsheet

How to Setup S3 Compatible Object Storage Server with Minio

Your support is our everlasting motivation,
that cup of coffee is what keeps us going!

As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.


Please enter your comment!
Please enter your name here