Samba Server Installation and Configuration on CentOS 7

Want to support HowtoForge? Become a subscriber!
Submitted by howtoforge (Contact Author) (Forums) on Thu, 2014-07-17 13:42. :: CentOS | Linux | Samba | Storage

Samba Server Installation and Configuration on CentOS 7

Version 1.0
Author: Srijan Kishore
Last edited 17/July/2014

This guide explains how to configure samba server in CentOS 7 with anonymous & secured samba servers. Samba is an Open Source/Free Software suite that provides seamless file and print services to SMB/CIFS clients. Samba is freely available, unlike other SMB/CIFS implementations, and allows for interoperability between Linux/Unix servers and Windows-based clients.

1 Preliminary Note

I have a fresh installed CentOS 7.0 server, on which I am going to install the samba server. Off-course you need to have one windows machine to check the  samba server that must be reachable with the CentOS 7.0 server. My Centos 7.0 server have hostname & IP as


  • The Windows machine must be on same workgroup. To check the value in windows machine run the command at cmd prompt

net config workstation

It will be like this

Your windows machine must be at same Workstation domain as in CentOS 7.0 server, i.e. WORKGROUP in my case.

  • To make the windows machine reachable in windows proceed like this. In the run terminal & add  the entry of your server IP address

notepad C:\Windows\System32\drivers\etc\hosts

In my case it was like this, just save the values.

[...] centos

2 Anonymous samba sharing

First I will explain the methodology to install the samba with the anonymous sharing. To install samba run,

yum install samba samba-client samba-common

It will install samba with Version 4.1.1.

Now to configure samba edit the file /etc/samba/smb.conf before making changes I will make the backup of original file as  /etc/samba/smb.conf.bak

mv /etc/samba/smb.conf /etc/samba/smb.conf.bak

Further give the entries like this

vi /etc/samba/smb.conf

workgroup = WORKGROUP
server string = Samba Server %v
netbios name = centos
security = user
map to guest = bad user
dns proxy = no
#============================ Share Definitions ============================== 
path = /samba/anonymous
browsable =yes
writable = yes
guest ok = yes
read only = no


mkdir -p /samba/anonymous
systemctl enable smb.service
systemctl enable nmb.service
systemctl restart smb.service
systemctl restart nmb.service

Further CentOS 7.0 Firewall-cmd will block the samba access, to get rid of that we will run:

firewall-cmd --permanent --zone=public --add-service=samba

[root@server1 ~]# firewall-cmd --permanent --zone=public --add-service=samba
[root@server1 ~]#


firewall-cmd --reload

[root@server1 ~]# firewall-cmd --reload
[root@server1 ~]#

Now you can access the Centos 7.0 sharing in windows as follows, go to the Run prompt and type \\centos :


From windows machine just browse the folder and try to create a text file, but you will get an error of permission denied.


Check the permission for the shared folder.

ls -l

drwxr-xr-x. 2 root root 6 Jul 17 13:41 anonymous
[root@server1 samba]#

To allow anonymous user give the permissions as follows:

cd /samba

chmod -R 0755 anonymous/
chown -R nobody:nobody anonymous/

ls -l anonymous/

total 0
drwxr-xr-x. 2 nobody nobody 6 Jul 17 13:41 anonymous
[root@server1 samba]#

Further we need to allow the selinux for the samba configuration as follows:

chcon -t samba_share_t anonymous/

Now anonymous user can browse & create the folder contents.


You can cross check the content at server also.

ls -l anonymous/

total 0
-rwxr--r--. 1 nobody nobody 0 Jul 17 16:05 anonymous.txt
[root@server1 samba]#

3. Secured samba server

For this I will create a group smbgrp & user srijan to access the samba server with proper authentication

groupadd smbgrp

useradd srijan -G smbgrp

smbpasswd -a srijan

[root@server1 samba]# smbpasswd -a srijan
New SMB password:<--yoursambapassword
Retype new SMB password:<--yoursambapassword
Added user srijan.
[root@server1 samba]# 

Now create the folder viz secured in the /samba folder & give permissions like this

mkdir -p /samba/secured

Again we will have to allow to listen through Selinux:

cd /samba
chmod -R 0777 secured/
chcon -t samba_share_t secured/

Again edit the configuration file as :

vi /etc/samba/smb.conf

[secured] path = /samba/secured valid users = @smbgrp guest ok = no writable = yes browsable = yes

systemctl restart smb.service

systemctl restart nmb.service

Further check the settings as follows


[root@server1 samba]# testparm 
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[Anonymous]"
Processing section "[secured]"
Loaded services file OK.
Press enter to see a dump of your service definitions <--ENTER

	netbios name = CENTOS
	server string = Samba Server %v
	map to guest = Bad User
	dns proxy = No
	idmap config * : backend = tdb

	path = /samba/anonymous
	read only = No
	guest ok = Yes

	path = /samba/secured
	valid users = @smbgrp
	read only = No
[root@server1 samba]# 

Now at windows machine check the folder now with the proper credentials

You will again face the issue of permissions to give write permission to the user srijan do:

cd /samba
chown -R srijan:smbgrp secured/

Now samba user  have permissions to write in the folder. Cheers you have done with samba server in CentOS 7.0 :)

Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by bouzeghoub (not registered) on Thu, 2014-11-20 10:21.


configure Samba on Rhel/CentOS 7 with Active dirctory

Submitted by Ricardo Red (not registered) on Mon, 2014-11-03 13:44.
I tried to find something related to Centos 7 + Samba 4 as PDC in the forums but couldn't find any post!

Anyone did the setup sucessfully and could share the way it was done?

Thank you,
Submitted by fbys294 (not registered) on Fri, 2014-10-31 00:16.

Should be on Google top list for Samba centos setup. 

 Thank You

Submitted by Alze (not registered) on Mon, 2014-09-15 20:24.
Thank you !! It's perfect !
Submitted by SambaJama (not registered) on Thu, 2014-09-04 15:28.

Very good article Srijan, very clear information. The best guide I have seen. Others are either too long winded or miss some steps.

Submitted by grrrommm (registered user) on Sat, 2014-08-09 15:59.
Best manual I found when using Windows 7 clients. Thanks Srijan Kishore
Submitted by Chilling (not registered) on Sat, 2014-08-09 05:43.
Good job , thanks. where did you get the global option map to guest = bad user ?
Submitted by Anonymous (not registered) on Wed, 2014-08-06 07:56.
shouldn't "mv /etc/samba/smb.conf /etc/samba/smb.conf.bak" actually be cp instead of mv?
Submitted by Paul (not registered) on Fri, 2014-07-18 00:39.
This got me up and running, thank you so much!