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

2. Disable SELinux

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

# selinuxenabled && echo enabled || echo disabled

enabled

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.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

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.

[tecmintusers]
  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 \\172.16.25.126\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 \\172.16.25.126\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 http://www.samba.org/.

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. rolo says:

    smbclient -L tecmint
    Enter user’s password:
    Connection to tecmint failed (Error NT_STATUS_UNSUCCESSFUL)
    am I missing something?

  2. ankush jain says:

    Actually I have configure the samba server but i enter the command smbclient -L //tecmint/tecmintusers -U tecmint then a error message show

    Error NT_STATUS_BAD_NETWORK_NAME

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.