Tuesday 2 September 2014

Samba server installation step by step on CentOS 6.x or redhat 6.x


Samba server installation step by step on CentOS 6.x  or redhat 6.x.

Samba is a client/server system that implements network resource sharing for Linux & Windows computers. Through Samba server Printer can be shared linux & windows machine.



To install the samba package,enter the following command:

# yum install samba samba-client samba-common

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


# smbd --version
  Version 3.6.9-167.el6_5

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


# chkconfig smb on
# chkconfig nmb on

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


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


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


# cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
# rm /etc/samba/smb.conf
# touch /etc/samba/smb.conf
# vi /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

:wq

# service smb restart
# service nmb restart

Change permission for samba share:


# chmod -R 0777 /home/samba/share


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






Add and manage Samba users and groups

Add a group in your CentOS server:

# useradd smbuser
# groupadd smbgrp
# usermod -a -G smbgrp smbuser
# smbpasswd -a smbuser

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

# cd /home/samba/
# mkdir secure
# chown -R arbab:smbgrp secure/
# chmod -R 0770 secure/
# 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

:wq

# service smb restart
# service nmb restart

Check the syntax error with testparm:


# testparm
Testing from Windows Machine:




No comments:

Post a Comment