There is a new version of this tutorial available for CentOS 8.

CentOS 6.2 Samba Standalone Server With tdbsam Backend

This tutorial explains the installation of a Samba fileserver on CentOS 6.2 and how to configure it to share files over the SMB protocol as well as how to add users. Samba is configured as a standalone server, not as a domain controller. In the resulting setup, every user has his own home directory accessible via the SMB protocol and all users have a shared directory with read-/write access.

I do not issue any guarantee that this will work for you!


1 Preliminary Note

I'm using a CentOS 6.2 system here with the hostname and the IP address

Please make sure that SELinux is disabled as shown in chapter 6 of this tutorial: The Perfect Server - CentOS 6.2 x86_64 With Apache2 [ISPConfig 3]


2 Installing Samba

Connect to your server on the shell and install the Samba packages:

yum install cups-libs samba samba-common

Edit the smb.conf file:

vi /etc/samba/smb.conf

Make sure you see the following lines in the [global] section:

# 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

This enables Linux system users to log in to the Samba server.

Then create the system startup links for Samba and start it:

chkconfig --levels 235 smb on
/etc/init.d/smb start


3 Adding Samba Shares

Now I will add a share that is accessible by all users.

Create the directory for sharing the files and change the group to the users group:

mkdir -p /home/shares/allusers
chown -R root:users /home/shares/allusers/
chmod -R ug+rwx,o+rx-w /home/shares/allusers/

At the end of the file /etc/samba/smb.conf add the following lines:

vi /etc/samba/smb.conf
  comment = All Users
  path = /home/shares/allusers
  valid users = @users
  force group = users
  create mask = 0660
  directory mask = 0771
  writable = yes

If you want all users to be able to read and write to their home directories via Samba, add the following lines to /etc/samba/smb.conf (make sure you comment out or remove the other [homes] section in the smb.conf file!):

   comment = Home Directories
   browseable = no
   valid users = %S
   writable = yes
   create mask = 0700
   directory mask = 0700

Now we restart Samba:

/etc/init.d/smb restart


4 Adding And Managing Users

In this example, I will add a user named tom. You can add as many users as you need in the same way, just replace the username tom with the desired username in the commands.

useradd tom -m -G users

Set a password for tom in the Linux system user database. If the user tom should not be able to log into the Linux system, skip this step.

passwd tom

-> Enter the password for the new user.

Now add the user to the Samba user database:

smbpasswd -a tom

-> Enter the password for the new user.

Now you should be able to log in from your Windows workstation with the file explorer (address is \\ or \\\tom for tom's home directory) using the username tom and the chosen password and store files on the Linux server either in tom's home directory or in the public shared directory.


Share this page:

Suggested articles

3 Comment(s)

Add comment


By: Ed Heron

CentOS creates a group with the same name as the user (unless over-written).  This is useful to give supervisory access.  We can use the technique to create groups.  When using this strategy, the smb.conf file doesn't have to be modified when creating group filespace.

For example, say you have users Tom and Harry.  They are both part of the sales group.  Suppose Tom is the manager and is allowed access to Harry's filespace.

Creating the users as normal:

useradd tom -m

useradd harry -m


Then creating the group is as simple as:

useradd sales -m


To append the sales space to Tom's list of groups:

usermod -a -G sales tom


Similarly, to give Harry access:

usermod -a -G sales harry


To give Tom access to Harry's filespace:

usermod -a -G harry tom


You would, of course, need to add the valid users (with %S), force group (with %S), create mask and directory mask stuff to the [homes] section.

I add a few items to hide dot files:

hide dot files = yes

veto files = /.*/

delete veto files = no


Also, I've had some creation rights issues that are resolved with:

force create mode = 660

force directory mode = 770

By: CanaDave

I couldn'd map Windows network drives to Samba shares until I added some ports to the firewall exceptions...

# nano /etc/sysconfig/iptables    (I use nano instead of vi)

...add the following to the list:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 137 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 138 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT

...then restart the firewall service

# service iptables restart

...then mapping to Samba shares from Windows was a breeze.

Thanks for the walkthrough!


I have some small problems after following this tutor:

I able to access the shared folder fine, but any new folders files copied to there cannot view the files only new directories. any tip o this.

I have no rproblem with ubuntu setup, but I like to get this work on CENTOS.