Friday, 24 January 2014

Share Folder Linux

How to install Samba server on CentOS 6

Part 1: Configuring anonymous share with samba server
To install the samba package,enter the following command:
sudo yum install samba samba-client samba-common
Description: http://rbgeek.files.wordpress.com/2012/05/426.jpg?w=630&h=63
Check the version of installed samba software by using this command:
smbd --version
Description: http://rbgeek.files.wordpress.com/2012/05/524.jpg?w=630&h=86
Configure the samba service, so that, it will start automatically at boot time:
sudo chkconfig smb on
sudo chkconfig nmb on
Description: http://rbgeek.files.wordpress.com/2012/05/on.jpg?w=630&h=100
Disable the SELinux:
sudo nano /etc/selinux/config
Description: http://rbgeek.files.wordpress.com/2012/05/157.jpg?w=630&h=73
Change SELinux from enforcing to disabled:
SELINUX=disabled
Description: http://rbgeek.files.wordpress.com/2012/05/230.jpg?w=630&h=230
Add these Iptables rules, so that samba will work perfectly:
sudo iptables -I INPUT 4 -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT
sudo iptables -I INPUT 5 -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT
sudo iptables -I INPUT 6 -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT
sudo service iptables save
Description: http://rbgeek.files.wordpress.com/2012/05/325.jpg?w=630&h=194
Restart the Server!!!
Go to your Windows machine and use this command in order to check the WORKGROUP name:
net config workstation
Description: http://rbgeek.files.wordpress.com/2012/05/625.jpg?w=630&h=76
It will show the output, something like this:
Description: http://rbgeek.files.wordpress.com/2012/05/720.jpg?w=630&h=315
Backup the smb.conf file, then delete it and create the new one:
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
sudo rm /etc/samba/smb.conf
sudo touch /etc/samba/smb.conf
sudo nano /etc/samba/smb.conf
Description: http://rbgeek.files.wordpress.com/2012/05/819.jpg?w=630&h=151
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 = /samba/share
 browsable =yes
 writable = yes
 guest ok = yes
 read only = no
Description: http://rbgeek.files.wordpress.com/2012/05/919.jpg?w=630&h=396
Save the smb.conf file and restart the service:
sudo service smb restart
sudo service nmb restart
Description: http://rbgeek.files.wordpress.com/2012/05/1016.jpg?w=630&h=144
Access the samba share from windows (where centos is the name of my samba server):
Description: http://rbgeek.files.wordpress.com/2012/05/centos.jpg?w=630
wao, we are able to access the samba share successfully Description: :-)
Description: http://rbgeek.files.wordpress.com/2012/05/centos12.jpg?w=630
Let’s try to create something, inside the share folder:
Description: http://rbgeek.files.wordpress.com/2012/05/1119.jpg?w=630&h=454
Error, we cannot create anything inside the share folder Description: :-(
Description: http://rbgeek.files.wordpress.com/2012/05/1213.jpg?w=630&h=350
Check the current permission on the samba share:
cd /samba/
ls -l
Description: http://rbgeek.files.wordpress.com/2012/05/1312.jpg?w=630&h=131
Change it, in such a way that everyone can read and write it(Check it, that it is allowed in your environment or not):
sudo chmod -R 0777 share
ls -l
Description: http://rbgeek.files.wordpress.com/2012/05/1412.jpg?w=630&h=129
Try to create something again, inside the share folder:
Description: http://rbgeek.files.wordpress.com/2012/05/158.jpg?w=630
Verify the newly created file on samba server:
cd share/
ls -l
Description: http://rbgeek.files.wordpress.com/2012/05/163.jpg?w=630&h=133
Part 2: Add and manage users and groups
Add a group in your CentOS server (in my case smbgrp):
sudo groupadd smbgrp
Description: http://rbgeek.files.wordpress.com/2012/05/174.jpg?w=630&h=82
Create a new share, set the permission on the share:
cd /samba/
sudo mkdir secure
sudo chown -R arbab:smbgrp secure/ 
ls -l 
sudo chmod -R 0770 secure/
ls -l
Description: http://rbgeek.files.wordpress.com/2012/05/181.jpg?w=630&h=296
Add the user to the samba group and create samba password:
sudo usermod -a -G smbgrp arbab
sudo smbpasswd -a arbab
Description: http://rbgeek.files.wordpress.com/2012/05/191.jpg?w=630&h=142
Edit the smb.conf file:
sudo nano /etc/samba/smb.conf
Description: http://rbgeek.files.wordpress.com/2012/05/201.jpg?w=630&h=76
Add the newly created samba share in smb.conf file:
[Secure]
path = /samba/secure
 valid users = @smbgrp
 guest ok = no
 writable = yes
 browsable = yes
Description: http://rbgeek.files.wordpress.com/2012/05/2110.jpg?w=630&h=395
Restart the samba service:
sudo service smb restart
sudo service nmb restart
Description: http://rbgeek.files.wordpress.com/2012/05/2210.jpg?w=630&h=133
Check the syntax error with testparm:
sudo testparm
Description: http://rbgeek.files.wordpress.com/2012/05/232.jpg?w=630&h=393
Testing from Windows Machine:
Description: http://rbgeek.files.wordpress.com/2012/05/241.jpg?w=630&h=492
Description: http://rbgeek.files.wordpress.com/2012/05/251.jpg?w=630&h=493
Verification from CentOS server:
cd /samba/secure/
ls -l 
Description: http://rbgeek.files.wordpress.com/2012/05/261.jpg?w=630&h=129


1 comments: