Samba is a opensource tool which is used to intractability between Windows and Linux with Samba server users can share the directory, printers with with windows as well as Linux system. Samba Servers also allows Linux users to access content shared by Windows.

Step-1 : Check whether the Samba and Samba-client packages is install by default or not

First of all we have to configure Samba on server side. In this command if anything shows in output means the packages are installed by default. If no output is present then we need to to install the packages using Step-2 of this tutorial.

[root@techbrown ~]# rpm -q samba samba-client -y

Samba-client already installed so that only install samba

Step-2 : Install the package using DNF package manager

[root@techbrown ~]# dnf install samba samba-client -y

Step-3 : As soon as installation completes start the services of Samba

In samba there is two services which user have to start.

  1. SMB : Server Message Block it is a protocol which is used to sharing such as files, printers, mail slots, serial ports etc.
  2. NMB : It is a server which understand and reply to the netbios over IP & domain.
[root@techbrown~]# systemctl start smb nmb

Step-4 : Enable the services of Samba so that it will survive during boot

[root@techbrown~]# systemctl enable smb nmb

It will show given output:

ln -s '/usr/lib/systemd/system/smb.service' '/etc/systemd/system/multi-
ln -s '/usr/lib/systemd/system/nmb.service' '/etc/systemd/system/multi-

Step-5 : Add the Samba Service to the firewalld firewall for communicating with Samba

[root@techbrown~]# firewall-cmd --permanent --add-service=samba

It will show given output:


Step-6 : When done reload the firewalld to activate the new rules

[root@techbrown~]# firewall-cmd --reload

It will show given output:


Step-7 : Check firewalld whether rules are added or not using a given command

[root@techbrown~]# firewall-cmd –list-all

Step-8 : Set the SElinux boolean policy for Samba

It will take some time to set up boolean policies.

[root@techbrown~]# setsebool -P samba_enable_home_dirs on
[root@techbrown~]# setsebool -P smbd_anon_write on

Step-9 : Create a Directory which user wants to share with other systems

[root@techbrown~]# mkdir /techbrown

Step-10 : Change the context type of directory

[root@techbrown~]# semanage fcontext -a -t samba_share_t '/techbrown(/.*)?'

Step-11 : Set the security contexts

[root@techbrown~]# restorecon -vvFR /techbrown/

It will show given output:

restorecon reset /techbrown context unconfined_u:object_r:default_t:s0-

Step-12 : Check whether the given context is applied or not to the directory

[root@techbrown~]# ll -ldZ /techbrown/

It will show given output:

drwxr-xr-x. root root unconfined_u:object_r:samba_share_t:s0 /techbrown/

Step-13 : Create the user to access the samba share.

[root@techbrown~]# useradd pro

Step-14 : Set the samba password to the user.

Samba password file smbpasswd is encrypted  format password file. this file contains user ids, and passwords and all account information.

[root@techbrown~]# smbpasswd -a pro

It will show given output:

New SMB password :techbrown

Hit ENTER then it will show given output:

Retype new SMB password: techbrown

Hit ENTER then it will show given output:

Added user pro.

Step-15 : Configure share directory in the configuration file.

The configuration file for samba is smb.conf this file available in /etc/samba/smb.conf in this file user have to specify the workgroup. and add the information related to the SHARE, add share name and allowing users.  have to add the hosts which allows to access the share.

In this tutorial workgroup is tech, user is pro, share name is techsamba, share directory /techbrown

[root@techbrown~]# vim /etc/samba/smb.conf

It will show given output:

Line No 89 : workgroup = tech
end of the Document:
valid users=pro
read list=pro
hosts allow=127. 172.25.2.

Step-16 : Check whether the Samba Configuration file Systematically correct or not.

[root@techbrown~]# testparm

after this command is used it will show the configuration which  user configured

Step-17 : Restart the Services for set up all configuration which user made.

[root@techbrown~]# systemctl restart smb nmb

Step-18 : Now, Check whether the share is accessible or not the user and hosts which mentioned in configuration file.

[root@techbrown~]# smbclient // -U pro
Enter pro's password:

Enter the samba password which is given to user pro. and check user pro is able to access to share.

Domain=[tech] OS=[Unix] Server=[Samba 4.1.1]
smb: \> ls
. D 0 Wed Mar 24 10:12:30 2020
.. D 0 Wed Mar 24 10:12:30 2020
40913 blocks of size 262144. 27465 blocks available

The tech share is successful shared and user pro is able to access the share.

That’s all for now.

How to Configure ISCSI Target Server on CentOS / RHEL

Previous article

How To Configure Samba Server in Multi User Mode on CentOS / RHEL

Next article

You may also like


Leave a reply

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

More in Linux