Installation and Configuration of Samba on CentOS

What is SAMBA?

A Samba is support for SMB (Server Message Block) via a package which is provided by Linux system. It is open source software which uses TCP/IP protocol. It provide printer and file sharing facility uses by Microsoft windows which is known as SMB. Samba can provide:

  • Share printers and files with Microsoft Windows, OS/2, Netware, and UNIX systems.
  • It can establish a simple name server for identifying systems on your local area network.
  • It can help backup PC files to a  Linux system and restore them for future use.
  • It can also provide Administer users and passwords.


Step 1-

Before installing Samba we have to install some packages in Enterprise Linux system. We can also download/install packages form YUM server by using“yum install” command.

  • samba       #### basic Samba packages
  • samba-client       #### samba client

Step 2-

For installing all the required packages:

  • # yum install samba
  • # yum install samba-client

Step 3-

Suppose you have an active directory setup for using it, install below packages also.

  • # yum install samba-winbind
  • # yum install samba-winbind-clients
  • # yum install samba-winbind-krb5-locator

Step 4-

Below are the lists of all the packages which will be-installed once you have installed the above packages.

  • samba-libs
  • samba-winbind-krb5-locator
  • samba-winbind-modules
  • samba-vfs-glusterfs
  • samba-winbind
  • samba-client
  • samba-common
  • samba-winbind-clients
  • samba


The configuration of Samba is generally comes under the path/etc/samba/smb.conf which contains all the configuration parameters related to samba. Here we provide some basic steps to configure a samba share.

Step 1-

For the share to be accessible to a particular user, we must first create a user (XXXX) on the Linux server where the share resides as well.

  • # user_add XXXX
  • # password XXXX

Changing the password of user XXXX.

New password:

Retype new password:

password: all authentication tokens updated successfully.

Step 2-

To add activate the Samba user and set the password, use the “smbpasswd” command with the -a option.

  • # smbpassword -a XXXX

Step 3-

For sharing information create the directory or we can use an existing directory. Also set full permissions on the directory.

  • # mkdir -p  /path/to/share
  • # chmod -R 777 /path/to/share

Step 4-

Next step is to set the SElinux contexts on the share. Verify if you can create a file in the share.

  • # chcon -R -t samba_share_t /path/to/share
  • # cd /path/to/share
  • # echo test > testfile.txt

Step 5-

Edit the /etc/samba/smb.conf file and add the share settings.

  • # vi /etc/samba/smb.conf


                   path = /path/to/share

                   comment = samba share for john

                   public = yes

                    writable = yes

                   create mask = 0777

                   browseable = yes

Step 6-

Now we have to verify current Samba setting by running the below command:

  • # 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 “[print$]”

Processing section “[Anonymous]”

Loaded services file OK.


Press enter to see a dump of your service definitions

# Global parameters


          netbios name = centos

          printcap name = cups

          security = USER

          idmap config * : backend = tdb

          cups options = raw


          comment = Home Directories

          browseable = No

          inherit acls = Yes

          read only = No

          valid users = %S %D%w%S


          comment = All Printers

          path = /var/tmp

          browseable = No

          printable = Yes

          create mask = 0600


          comment = Printer Drivers

          path = /var/lib/samba/drivers

          create mask = 0664

          directory mask = 0775

          write list = root


          comment = Anonymous File Server Share

          path = /srv/samba/anonymous

          force user = nobody

          guest ok = Yes

          read only = No

Step 7-

Restart the whole samba services for the above settings to take effect.

  • # service smb restart
Follow US:

Leave a Reply

Your email address will not be published. Required fields are marked *