Build a powerful Samba Server using Debian 9

Debian 9 is a powerful Linux distribution for both Desktop and Server. Today we will show you how to build a powerful Samba Server using Debian 9. With Samba enabled on Debian 9, we can then access the shared directory from other computer in the network. Samba is a great server software to communicate between Linux with Windows based system.

What you will learn

We will guide you how to install Samba and configure it on Debian 9 and all its derivatives.

System Configuration

  • IP address: 10.34.0.202
  • OS: Debian 9 Stretch

Steps to install and configure Samba on Debian 9

Step 1. Install Samba

apt install samba

Output sample

root@debian:~# apt install samba
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libglib2.0-0 libglib2.0-data shared-mime-info xdg-user-dirs
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
  attr libavahi-client3 libavahi-common-data libavahi-common3 libcups2 libfile-copy-recursive-perl
  libgpgme11 libldb1 libtalloc2 libtdb1 libtevent0 libwbclient0 python-crypto python-dnspython python-ldb
  python-samba python-talloc python-tdb samba-common samba-common-bin samba-dsdb-modules samba-libs
  samba-vfs-modules tdb-tools update-inetd
Suggested packages:
  cups-common gpgsm python-crypto-dbg python-crypto-doc python-gpgme bind9 bind9utils ctdb ldb-tools ntp
  | chrony smbldap-tools winbind ufw heimdal-clients
The following NEW packages will be installed:
  attr libavahi-client3 libavahi-common-data libavahi-common3 libcups2 libfile-copy-recursive-perl
  libgpgme11 libldb1 libtalloc2 libtdb1 libtevent0 libwbclient0 python-crypto python-dnspython python-ldb
  python-samba python-talloc python-tdb samba samba-common samba-common-bin samba-dsdb-modules samba-libs
  samba-vfs-modules tdb-tools update-inetd
0 upgraded, 26 newly installed, 0 to remove and 1 not upgraded.
Need to get 10.5 MB of archives.
After this operation, 53.1 MB of additional disk space will be used.
Do you want to continue? [Y/n]

Step 2. Configure Samba

Here we will make some changes to the Samba configuration file. You may use your favorite editor such as vi or nano. I will only show some basic configuration that should works for most situation.

nano /etc/samba/smb.conf
#Change the the workgroup with your own
workgroup = WORKGROUP

#Create a new share
[Database]
path = /shares/Database
writable = yes
create mode = 0770
directory mode = 0770
guest ok = no

Now we will create a new group and new folder that will be shared to the network

#create new group i.e gis
groupadd gis

#create new directory
mkdir -p /shares/Database

#Modify the permission
chgrp gis /shares/Database
chmod 770 /shares/Database

Now we need to create new user that can access the Samba shared folder

#add new samba user
smbpasswd -a dhani

#add the user to gis group
usermod -G gis dhani

#restart samba
systemctl restart smbd

Now we can access our new shared folder from other computer.

Admin

Leave a Reply

Your email address will not be published. Required fields are marked *