Daily Archives: February 23, 2015

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 ~]# 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 .

[root@localhost ~]# useradd shareuser -s /sbin/nologin

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.

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

[root@localhost ~]# mkdir /share

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 .



[share]
comment = insert any comments here
path = /share
public = no
printable = no
writable = yes
valid users = shareuser
create mask = 0765

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”


;[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.

Cheers ..