How to configure samba on centos

Information TechnologyLinuxCentos 7

This article will guide to configure samba server in CentOS 6.x with anonymous & secured samba folders. Samba is an Open Source/Free Software suite that provides seamless access to the file services to SMB/CIFS clients. Unlike other tools samba SMB/CIFS implementations will allow to share folders between Linux servers and Windows clients.


Install the samba package using this command

# yum -y install samba
# mkdir /samba

Give folder permission to the samba server

# chmod -R 0755 /samba/anonymous/

You need to modify the smb.conf file in /etc/samba/smb.conf

For security reasons, I am taking the backup of the original file in /etc/samba/smb.conf

# cp /etc/samba.smb.conf /etc/samba.smb.conf.old

For removing the confusion, will delete the configuration file and will create a file with the below commands.

# rm -rf /etc/samba.smb.conf
# vi /etc/samba/smb.conf

Configuration File Settings

#======================= Global Settings =====================================
workgroup = WORKGROUP
security = share
map to guest = bad user
#============================ Share Definitions ==============================
path = /samba/anonymous/
browsable =yes
writable = yes
guest ok = yes
read only = yes

Start the Service Samba Server Services

# service smb restart

Accessing the Share from Windows

Now you can access the share from windows machine using \\IP-ADDRES from Start -> Run. (Ex: \\

Securing the Samba Share

As we share the files without any security there is a chance of loosing your valuable data to secure please do the settings.

# groupadd smbgrp
# useradd user1 -G sambagrp
# smbpasswd -a user1
New SMB password:<--yoursambapassword
Retype new SMB password:<--yoursambapassword

Now create the folder with the name secured in the /samba folder and give permissions like this −

# mkdir -p /samba/secure
# cd /samba
# chmod -R 0777 /samba/secure/

Again edit the configuration file −

# vi /etc/samba/smb.conf
path = /samba/secure
valid users = @smbgrp
guest ok = no
writable = yes
browsable = yes
# service smb restart

Further, check the settings as follows

# 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

Edit the Configuration files with both anonymous and secure to see the difference in shares.

# vi /etc/samba/smb.conf
Configuration file settings:
#======================= Global Settings =====================================
netbios name = CENTOS
server string = Samba Server %v
map to guest = Bad User
dns proxy = No
idmap config * : ackbend = tdb
#============================ Share Definitions ==============================
path = /samba
read only = No
guest ok = Yes
path = /samba/secure
valid users = @smbgrp
guest ok = no
writable = yes
browsable = yes

Now you can access the share from windows machine \\IP-ADDRES from Start -> Run. (Ex: \\

This will ask for the user-name and password provide the user-name and password (Ex: user1 and password for the user1) and now you can access the secured folder using credentials.

Conclusion − After the configuration and successful setup, now you are able to access the folder Windows share (or) NTFS share on a Linux server to provide or share the data in between Windows and Linux machines, with or without anonymous access and you are able to provide the individual access or groups access to the folders with permissions.

Published on 18-Oct-2019 16:15:36