• Man Jadda Wajada

Install and Configure Samba Server Share on Debian 10 / Ubuntu 18.04

Welcome to our guide on how to install and configure Samba Share on a Debian 10 server (Buster) & Ubuntu 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 18.04

To install Samba on Debian 10 Buster / Ubuntu 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.

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 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.

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.

Komentari Tulisan Ini
Tulisan Lainnya
How to Install and Configure OpenLiteSpeed Web Server on Debian 10

on this page Requirements Getting Started Install and Configure OpenLiteSpeed Install MariaDB for OpenLiteSpeed Install PHP for OpenLiteSpeed OpenLiteSpeed is a free, open-source

31/05/2020 07:06 WIB - Administrator
Install WordPress on Debian 10

In today’s world, everything is Internet and information sites. There is too much variety in them. But we also find a lot of variety of applications that allow us to make websites

02/05/2020 09:42 WIB - Administrator
How To Rewrite URLs with mod_rewrite for Apache on Debian 10

Introduction Apache’s mod_rewrite module lets you rewrite URLs in a cleaner fashion, translating human-readable paths into code-friendly query strings. It also lets yo

09/02/2020 15:19 WIB - Administrator
How To Rewrite URLs with mod_rewrite for Apache on Debian 10

Introduction Apache’s mod_rewrite module lets you rewrite URLs in a cleaner fashion, translating human-readable paths into code-friendly query strings. It also lets yo

09/02/2020 15:08 WIB - Administrator
Enable userdir, users can build websites with this config.

Enable userdir, users can build websites with this config. [1] Configure Apache2 for Userdir.   root@www:~#  a2enmod userdir Enabling module userdir. To act

16/11/2019 18:25 WIB - Administrator
Download Owncloud

Debian_9.0 owncloud-files-10.2.1-1+1.3 Add (at least temporarily) a download repository. This requires registering trusted key. (More information). Run the following shell commands as r

29/10/2019 18:44 WIB - Administrator
NextCloud vs ownCloud vs Seafile vs Syncthing

pengantar Sinkronisasi file adalah cara bagi individu dan perusahaan untuk membuat cadangan file penting misi mereka pada drive eksternal atau server. Sangat penting untuk memiliki

29/10/2019 18:33 WIB - Administrator
Belajar VPN yuk

27/10/2019 14:25 WIB - Administrator
How To Install Nextcloud on Debian 10 Buster Linux

Nick Congleton Debian 27 June 2019   Contents 1. Software Requirements and Conventions Used 2. Install the Required Packages 3. Set Up Your Database 4.&nb

23/10/2019 09:54 WIB - Administrator
The Perfect Server - Debian 10 (Buster) with Apache, BIND, Dovecot, PureFTPD and ISPConfig 3.1

On this page 1 Preliminary Note 2 Install the SSH server (Optional) 3 Install a shell text editor (Optional) 4 Configure the Hostname 5 Update your Debian Installation 6. Change t

23/10/2019 09:44 WIB - Administrator