Installing and configuring samba on centOS

Samba is free software mainly used for file sharing between other platforms ( Windows ) using  SMB/CIFS protocol .Default centos 6 installation will not include samba packages , you need install manually .Here we can see how to install and configure samba using yum.

Step 1 » Update yum repositories and packages by typing the below command

 

[root@localhost ~]# rpm -qa | grep samba

[root@localhost ~]# yum update

Step 2 » Install samba packages along with dependencies using yum

[root@localhost ~]# yum install samba

Samba configuration :

Step 3 » Create a share username and password & Group

[root@localhost ~]# adduser shareuser

Now create samba password for username shareuser using smbpasswd command .


[root@localhost ~]# smbpasswd -a shareuser
New SMB password:****
Retype new SMB password:****
Added user shareuser.

[root@Fileserver ~]# tail /etc/passwd

[root@Fileserver ~]# groupadd sambauser

[root@Fileserver ~]# gpasswd -M IT,fashion sambauser

[root@Fileserver ~]# chgrp sambauser /home/samba

[root@Fileserver ~]# chmod 2770 /home/samba -R

Step 4 »  Create a folder called share in the root directory .

[root@localhost ~]# mkdir /share -p

and change the ownership for the share folder

[root@localhost ~]# chown -R shareuser:root /share/

Step 5 »  open the file /etc/samba/smb.conf . ( Before editing the file , please copy the file to another location for backup ) . Add the below lines at the bottom of the file .

Open up /etc/samba/smb.conf and add the following lines to each share:

veto files = /._*/.DS_Store/*.exe/*.com/*.dll/*.bat/*.vbs/*.tmp/*.mp3/
delete veto files = yes

[root@localhost ~]# chmod 2770 /home/samba -R


[root@localhost ~]# vim /etc/samba/smb.conf
[share]
comment = insert any comments here
path = /share
public = no
printable = no
writable = yes
valid users = shareuser
write list = shareuser
invalid users = admin
create mask = 0765
Veto files = /*.exe/*.com/*.dll/*.bat/*.vbs/*.tmp/*.mp3/

Step 6 » start samba service


[root@localhost ~]# service smb start

and type this below command to start samba service automatically while booting.


[root@localhost ~]# chkconfig --levels 235 smb on

Samba testing :

Step 7 » You can check  your configuration by using testparm command


[root@localhost ~]# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[homes]"
Processing section "[printers]"
Processing section "[share]"
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions
[global]
workgroup = MYGROUP
server string = Samba Server Version %v
log file = /var/log/samba/log.%m
max log size = 50
cups options = raw
[homes]
comment = Home Directories
read only = No
browseable = No
[printers]
comment = All Printers
path = /var/spool/samba
printable = Yes
browseable = No
[share]
comment = Share
path = /share
valid users = shareuser
read only = No

You can see your share sections. Here by default home folders of users will be displayed . you can comment the unwanted section using “;” symbol .

For example . you can comment homes section as below and restart the service using  “service smb restart”


[root@localhost ~]# service smb restart
[root@localhost ~]# chkconfig smb on
[root@localhost ~]# service nmb restart
[root@localhost ~]# chkconfig nmb on

Step 7 » Firewall Disable & selinux OFF


[root@localhost ~]# service iptables stop
[root@localhost ~]# getenforce 0

;[homes]
;comment = Home Directories
;read only = No
;browseable = No

Now you can access share folder on windows machine by typing \samba-server-ip on run prompt . you can see your share folder after entering username and password.

Show All Users on your samba server


[root@localhost ~]# tail /etc/passwd

Cheers ..

Advertisements

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