Easy configure Samba on CentOS

Samba is a client/server system that implements network resource sharing for Linux and other UNIX computers. With Samba, UNIX files and printers can be shared with Windows clients and vice versa. Samba supports the Session Message Block (SMB) protocol. Nearly all Windows computers include SMB support with their internal network subsystems (NetBIOS in particular).
With an appropriately-configured Samba server on Linux, Windows clients can map drives to the Linux filesystems. Likewise, theSamba client on UNIX can connect to Windows shares by their UNC name. Although differences among various operating systems (such as filesystem naming conventions, end-of-line conventions, and authentication) can limit interoperability, Samba offers a generally serviceable mechanism for resource sharing on a heterogenous network.

Install Samba on CentOS 6.0/6.1/6.2/6.3/6.4/6.5

To install the samba package,enter the following command:


  1. # yum install samba samba-client samba-common

Check the version of installed samba software by using this command:


  1. # smbd –version

Check Samba version

Check Samba version

Configure the samba service, so that, it will start automatically at boot time:


  1. # chkconfig smb on
  2. # chkconfig nmb on

Add these Iptables rules, so that samba will work perfectly:


  1. # iptables -I INPUT 4 -m state –state NEW -m udp -p udp –dport 137 -j ACCEPT
  2. # iptables -I INPUT 5 -m state –state NEW -m udp -p udp –dport 138 -j ACCEPT
  3. # iptables -I INPUT 6 -m state –state NEW -m tcp -p tcp –dport 139 -j ACCEPT
  4. # service iptables save

Backup the smb.conf file, then delete it and create the new one:


  1. # cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
  2. # rm /etc/samba/smb.conf
  3. # touch /etc/samba/smb.conf
  4. # nano /etc/samba/smb.conf

Add these lines, in your smb.conf file (or change it according to your requirement):
#======================= Global Settings =====================================
[global]
workgroup = WORKGROUP
security = share
map to guest = bad user
#============================ Share Definitions ==============================
[MyShare]
path = /home/samba/share
browsable =yes
writable = yes
guest ok = yes
read only = no

Save the smb.conf file and restart the service:


  1. # service smb restart
  2. # service nmb restart

Change permission for samba share:


  1. # chmod -R 0777 /home/samba/share

Access the samba share from windows (where 192.168.1.15 ip address of my samba server):

Access to Samba share

Access to Samba share

Successfully access to Samba share

Successfully access to Samba share

Add and manage Samba users and groups

Add a group in your CentOS server:


  1. # useradd smbuser
  2. # groupadd smbgrp
  3. # usermod -a -G smbgrp smbuser
  4. # smbpasswd -a smbuser

Create a new share, set the permission on the share:


  1. # cd /home/samba/
  2. # mkdir secure
  3. # chown -R arbab:smbgrp secure/
  4. # chmod -R 0770 secure/

Edit the smb.conf file:


  1. # vi /etc/samba/smb.conf

Add the newly created samba share in smb.conf file:
[Secure]
path = /home/samba/secure
valid users = @smbgrp
guest ok = no
writable = yes
browsable = yes

Create new samba share

Create new samba share

Restart the samba service:


  1. # service smb restart
  2. # service nmb restart

Check the syntax error with testparm:


  1. # testparm

Testing from Windows Machine:

Test samba sharing

Test samba sharing

Source: http://lintut.com/easy-samba-server-installation-on-centos-6-5/

One comment on “Easy configure Samba on CentOS

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s