Setup Samba Server Using tdbsam Backend on RHEL/CentOS 6.3/5.8 and Fedora 17-12

Samba is an open source and most popular widely used program that enables end users to access Linux shared directory from any windows machine on the same network. Samba is also named as a network file system and can be installed on Linux/Unix operating systems. Samba itself is a client/server protocol of SMB ( Server Message Block) and CIFS (Common Internet File System). Using windows smbclient (GUI) or file explorer, end users can connect to Samba server from any windows workstations to access shared files and printers.

Samba Server Setup

Samba Server Setup

This tutorial explains how to setup Samba Server (fileserver) Using tdbsam Backend on RHEL 6.3/6.2/6.1/6/5.8, CentOS 6.3/6.2/6.1/6/5.8 and Fedora 17,16,15,14,13,12 systems and also we will learn how to configure it to share files over the network using SMB protocol, as well as we will see how to create and add system users on samba user’s database.

1. Preliminary Note

We are using RHEL 6.3 system with hostname tecmint with IP address

2. Disable SELinux

First, check whether SELinux is currently enabled or disabled with following command.

# selinuxenabled && echo enabled || echo disabled


In our case, SELinux is currently enabled, so we need to disabled it under RHEL/CentOS/Fedora systems, open file called /etc/selinux/config with your choice of editor. ( Ignore this step, if SELinux is already disabled ).

# vi /etc/selinux/config

And change the line that says SELINUX=enabled to SELINUX=disabled and reboot the system.

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.

3. Rebooting System

Here, we will need to reboot the system to re-lable entire file system in the boot process. This reboot process can take some time, depends on the volume of files.

# init 6

Once the system comes to login prompt, login with root user and start installing Samba package.

3. Installing Samba

We use YUM package manager tool to install Samba packages.

# yum install samba samba-common cups-libs samba-client

4. Configure Samba with tdbsam Backend

Once samba installed successfully, now time to configure it using tdbsam password backend. Open file /etc/samba/smb.conf.

# vi /etc/samba/smb.conf

And check for the following lines in the Standalone Server Options section. This line enables users to login into Samba server.

# ----------------------- Standalone Server Options ------------------------
# Scurity can be set to user, share(deprecated) or server(deprecated)
# Backend to store user information in. New installations should
# use either tdbsam or ldapsam. smbpasswd is available for backwards
# compatibility. tdbsam requires no further configuration.

        security = user 
        passdb backend = tdbsam

5. Creating Samba Share Directory

Now, we will create Samba share directory for sharing files for all users. Run the following commands.

# mkdir -p /home/sambashares/tecmintusers
# chown -R root:users /home/sambashares/tecmintusers
# chmod -R 775 /home/sambashares/tecmintusers

6. Configuring Samba Share Directory

Add following lines at the bottom of the file /etc/samba/smb.conf.

  comment = All Users
  path = /home/sambashares/tecmintusers
  valid users = @users
  force group = users
  create mask = 0660
  directory mask = 0771
  writable = yes

7. Creating Samba Start-up Links

Create system start-up links for Samaba.

# chkconfig --levels 235 smb on

8. Restarting Samba Server

Now restart Samba server.

# /etc/init.d/smb restart

9. Creating Samba Users

We will create a user called tecmint and set password to it.

# useradd tecmint -m -G users
# passwd tecmint

Now add newly created user tecmint to Samba user database and set password for him.

# smbpasswd -a tecmint

This way you can create as many as users you want, just replace the username tecmint with the desired username.

10. Verify Samba Server Share

Verify Samba share directory within Linux system using smbclient package with -L option. It will display list of available samba share directories on the host tecmint.

# smbclient -L tecmint

Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.5.10-125.el6]

        Sharename       Type      Comment
        ---------       ----      -------
        tecmintusers    Disk      All Users
        IPC$            IPC       IPC Service (Samba Server Version 3.5.10-125.el6)
Anonymous login successful
Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.5.10-125.el6]

        Server               Comment
        ---------            -------

        Workgroup            Master
        ---------            -------

Try to login into Samba share directory under Linux system using username as tecmint with password.

# smbclient -L //tecmint/tecmintusers -U tecmint
Enter tecmint's password:
Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.5.10-125.el6]

        Sharename       Type      Comment
        ---------       ----      -------
        tecmintusers     Disk      All Users
        IPC$            IPC       IPC Service (Samba Server Version 3.5.10-125.el6)
        tecmint         Disk      Home Directories
Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.5.10-125.el6]

        Server               Comment
        ---------            -------

        Workgroup            Master
        ---------            -------

11. Login to Samba Server from Windows

Now try to login from your Windows system, open Windows Explorer and type the address \\\tecmint and enter username as tecmint and password, you will see tecmint’s home directory. Refer screenshot below.

Samba Share on Windows

Samba Share on Windows

Now to share Samba shared directory type address as \\\tecmintusers. You will see similar to below.

Samba Share Directory on Windows

Samba Share Directory on Windows

For more information about Samba configuration see the

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Ravi Saive

I am Ravi Saive, creator of TecMint. A Computer Geek and Linux Guru who loves to share tricks and tips on Internet. Most Of My Servers runs on Open Source Platform called Linux. Follow Me: Twitter, Facebook and Google+

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

16 Responses

  1. Adonis says:

    I really think you should not disable Selinux, at most, put it in “permissive” mode, it won’t enforce security, but still log any issue!

  2. Ronnie Gainey says:

    I am trying to install samba directory to use between my host CentOS 6.5 and VM Windows 7 enterprise. How do i connect to each machine through the virtual adapter?

  3. Anuj Bhatnagar says:

    The purpose of that command is to change the context of file (i.e chcon) and samba_share_t is used to allow the given path required authority to be shared up via samba server (i.e between windows & linux)

  4. faruk abdullah says:

    what is the use of #chcon -R -t samba_share_t /home/sambashares/tecmintusers. can you explain please ?

  5. sitanagarajoo says:

    i am using oracle linux server 6.0 santigo
    i haveinstalled printer working in server, but could not print from windows pc and if printer connected to windows pc then also could not print. but i can exchange files (copy. paste delete) both in windows and linux.

    please help me

  6. colin says:

    # enforcing – SELinux security policy is enforced.
    # permissive – SELinux prints warnings instead of enforcing.
    # disabled – No SELinux policy is loaded.

    Why use disabled over permissive? Disabled means that SE security contexts are not created and that you cannot easily turn SE linux back on.

    Ideally we should have the SE contexts posted above, for those that want to turn it on (ie you have a server exposed to the web OR you care about security.

  7. Gokul Nair says:

    k yar, Thanks. I could able to access from windows machine. But every day the first access to the share take 40-45 seconds delay, after that there is no more delay for that day. The next day again the same thing happens.

  8. Gokul Nair says:

    yar, I got the error ‘Connection to bhshare failed (Error NT_STATUS_BAD_NETWORK_NAME)’ when executing ‘smbclient -L bhshare’

    • Ravi Saive says:

      Don’t worry about that error, even I got the same while writing up this article. Try whether Samba is accessible from Windows machine.

    • scarto says:

      Hi all you need to make port forwarding this example is for Centos
      -A INPUT -m state –state NEW -m tcp -p tcp –dport 139 -j ACCEPT

  9. Ariel Chiong says:

    HI All,

    Just a question, how can you access through domain name?

    the example you provide is an IP


    i want know how in domain name



    how or where do you configure this kind of adjustment

  10. Vijay Kumar Khurava says:

    Hi Ravi,

    Needed your help in AD domain joining on RHEL 6.3 imaged desktops.

    We have multiple system imaged with RHEL v6.3 & want to join them in windows domain. Please help us.

Got something to say? Join the discussion.

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.