Connect with us

Hi, what are you looking for?

Linux

How to configure Samba Server on CentOS 7

What is Samba?

Samba is open source software and it uses the TCP / IP protocol. Basically the samba is an implementation of SMB (server message block) and CIFS (common internet file system) protocol. The main advantage of samba is it provide file and print sharing services between Linux and Other O.S.

Samba supported platforms:

  • Linux
  • Windows
  • Solaris 2.above
  • Aix
  • OpenBSD
  • SunOS 4 above
  • and more…..

Samba Packages Quick Review

  • samba
  • samba-client
  • samba-common
  • samba-winbind
  • and some others

Configure SAMBA server for RHEL/CentOS/Scientific/Oracle Linux 7/6/5

STEP 1: Now check whether your yum is configured.
STEP 2: Check Necessary RPM’s
[root@techbrown ~ ]# rpm –qa samba
STEP 3: Install necessary RPM
[root@techbrown ~ ]# yum install samba* -y

The samba packages are installing now.
Red-Hat-Enterprise-Linux-6-2014-07-21-15-12-44-1024x614

SAMBA Daemons:

nmbd: The nmbd daemons provides NetBIOS (Network Basic Input/output system) nameserving and browsing support. A daemon that looks after the Windows Internet Name Service (WINS) and assist with browsing. But according to samba documentation, it should be the first daemon to start.
Smbd : It manages file transfers and authentication.
Winbind : It started to handle Microsoft Windows Domain membership.

To check status

[root@techbrown ~]# service nmb status
nmbd is stopped
[root@techbrown ~]# service smb status
smbd is stopped
[root@techbrown ~]# service winbind status
winbind is stopped

Configuration File:

The main configuration file is smb.conf and the path of configuration file is /etc/samba/smb.conf.
It is divided into four sections:
global : General samba configuration parameters.
homes : Allow users to access their home directories.
printers : Used for configuring printers and printers entries related to shared printers.
shares : Define other shares available.

STEP 4: So let’s start to configure SAMBA server on server side.

We share /techbrown file. So first create a /techbrown directory and create some files into /techbrown directory.

[root@techbrown ~]# mkdir /techbrown
[root@techbrown ~]# touch /techbrown/file {1..10}

Now we edit configuration file of samba and make some changes and entries in it.

Advertisement. Scroll to continue reading.
[root@techbrown ~]# vim /etc/samba/smb.conf

You can change a WORKGROUP from the global section.
Now go to the Share Definitions section. So we first see the Directory Sharing Options
[techbrown] -> Share name which will be displayed.
comment = Access files stores -> Comment displayed in Network.
path = /techbrown -> Path of directory associated with the share.
host allow = address -> Specify which domain can access this share ( Also you can make entry of it in global section).
host deny= address -> Specify which domain can’t access this share.
valid users = username -> Name of users who can access the share.
public = No/Yes -> Specify whether guest user can access this share or not.
writable = No/yes -> Specify whether the shared directory is writable or not.
browseable = No/Yes -> specify whether the shared directory should be visible or not.
So let’s start with our configuration.

[share]
path = /techbrown
host allow = 127.192.168.0
host deny = 192.168.0.24
browseable = yes
writable = yes
valid users = techbrown

Save this using :wq
Now it’s time to start your service.

[root@techbrown ~]# service smb start
Starting SMB services:                                     [  OK  ]
[root@techbrown ~]# chkconfig smb on

I already have user having username techbrown. If you want to add user follow these steps.

[root@techbrown ~]# useradd techbrown

Now it’s time to provide a password to the user.

[root@techbrown ~]# smbpasswd   -a  techbrown
New SMB password : ****
Retype new SMB password : ****

Added user techbrown.

Advertisement. Scroll to continue reading.
[root@techbrown ~]#

But because of SELINUX policy client will not get access from server. SELINUX is the complex security features of Linux. It will happen if your SELINUX configured as “enforcing” in targeted mode.
Let’s talk about some Booleans
samba_export_all_ro -> Enable read only access to any directory.
samba_export_all_rw -> Enable read write access to any directory.
samba_enable_home_dirs -> Enable the sharing of a home directory.
samba_share_t Directory name-> Enables which samba can share.
So we have to enable this policy. For this just do one thing.

[root@techbrown ~]# ls -ldZ /techbrown
drwxr-xr-x. root root unconfined_u:object_r:default_t:s0 /techbrown

So to enable SELINUX environment run chcon command to change the context.

[root@techbrown ~]# chcon -R -t samba_share_t /techbrown
[root@techbrown ~]# ls -ldZ /techbrown
drwxr-xr-x. root root unconfined_u:object_r:samba_share_t:s0 /techbrown
[root@techbrown ~]#

Now we are ready to use this share on Client side. To do this, you have to install samba-client package for Linux client. After that do following
“smbclient” command is use to connect with your share.
syntax
smbclient //ipaddr/sharename -U username

[root@techbrown ~]#  smbclient     //192.168.0.2/share  -U   techbrown
Enter techbrown's password: ****
Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.5.4-68.el6]
smb: \>

Check On windows client side

Right click on “My Computer” click on “properties”.
Capture1
Click on change setting
Capture2
Change workgropname with your Workgroupname.
Capture3
Capture4
Capture5
Start —-> Run.
Capture
It will ask you username and password, type it and access the file.
Congratulation now you have configured samba server.

Comments
Advertisement
Advertisement

Linux

In this tutorial we will configure ISCSI Target Server on CentOS 8 / RHEL 8. ISCSI stands for Internet Small Computer Systems Interface.  This...

Linux

In this tutorial we will configure SELinux Modes on CentOS 8 / RHEL 8. SELinux stands for Security-Enhanced Linux and it is developed by...

Linux

DNF stands Dandified YUM and this is the default package manager for RHEL 8 / CentOS 8.  This tutorial explains you how to create...

Linux

If you forget a root password of your RHEL 8 and CentOS 8 and want to reset the password so that the RHEL 8...

Windows

How to auto upgrade JioFi firmware for JioFi 2 / JioFi 3 / JioFi 4 / JioFi 5 / JioFi 6 and other JioFi...

Advertisement

You May Also Like

Windows

How to auto upgrade JioFi firmware for JioFi 2 / JioFi 3 / JioFi 4 / JioFi 5 / JioFi 6 and other JioFi...

Windows

Internet is the most important public network for connecting to the WEB. For internet connection requirement the ISP is required as well as it...

Windows

How to download and install the Mobile Intel 4 Series Express Chipset Graphics Drivers for Windows 10.  Windows 10 is the one of the...

Windows

How to Install and Configure PCSX2 on Windows 10. The Windows 10 is the most recommended operating system for the Games. In stream platform...