Samba Installation & Configuration

What is Samba?

Samba is a Linux tool or utility that helps to share resources like files, and printers with other operating systems.

It is similar to NFS. The difference is that NFS allows sharing within a Linux or Unix operating system while Samba shares with other operating systems like Windows, Mac, and so on.

For example, if computer 1 shares its file system with computer 2 using Samba then computer 2 will have the shared file system as if it is mounted as the local file system.

Samba shares its filesystem with the help of the SMB protocol(Server Message Block) developed by IBM. There is another protocol in Samba called the CIFS(Common Internet File System) and NMB(NetBios Name Server) from the Microsoft.

CIFS is now the extension of SMB. Also, there are newer versions of SMB - SMB v2 and v3.

Samba Installation

For Samba installation, we should have client and server machine configuration.

Steps of Samba Installation are:

Login to the server machine and follow the steps :

  • Become a root user, with the command:
    su -​
  • Install the packages samba, samba-client, and samba-common, with the command:
    yum install samba samba-client samba-common​
  • Verify Samba is installed, with the command:
    rpm -qa | grep samba​
  • Enable Samba to be allowed through firewall(if we have a firewall running) with the commands:
    firewall-cmd --permanent --zone=public --add-service=samba
    firewall-cmd –reload​

  • To stop and disable firewall or iptables, run the commands:
    systemctl stop firewalld
    systemctl stop iptables
    systemctl disable firewalld
    systemctl disable iptables​
  • Create a Samba shared directory with the command:
    mkdir -p /samba/morepretzels​
  • Assign permissions to that directory with the command:
    chmod a+rwx /samba/morepretzels
  • Change its ownership permission to nobody with the command:
    chown -R nobody:nobody /samba​
  • Change the SELinux security for the Samba shared directory(if SELinux is enabled) with the command:
    chcon -t samba_share_t /samba/morepretzels​
  • Check the status of SELinux with the command:
  • If SELinux is enabled, run the command:
    vi /etc/selinux/config​
  • As the editor opens, search for SELINUX=enforcing change it to:
  • Save and quit.
  • Reboot the system, with the command:
  • Login as a root user, with the command:
    su -​
  • Modify /etc/samba/smb.conf file to add new shared filesystem with the commands:
    cd /etc/samba​/
    vi smb.conf
  • As the editor opens, delete everything from the smb.conf file and add the following parameters:
           workgroup = WORKGROUP
           netbios name = centos
           security = user
           map to guest = bad user
           dns proxy = no
           path = /samba/morepretzels
           browsable = yes
           writable = yes
           guest ok = yes
           guest only = yes
           read only = no​
  • Save and quit.
  • Verify the settings we have done with the command:
  • Once Samba is installed, enable and start its services with the commands:
    systemctl enable smb
    systemctl enable nmb
    systemctl start smb
    systemctl start nmb
  • Create a file apples under the shared directory /samba/morepretzels/ with the commands:
    cd /samba/morepretzels/
    touch apples​
  • Check the IP address of the machine, with the command:


The IP address is

Mount on the client Windows with the steps :

Move to the Windows machine. Go to Start. Then go to the Search bar. Enter the IP address of the Samba server machine.

  • The file apples that we created shall be available under the Anonymous folder in Windows.
  • Create a text document yadainside the same location.
  • Go to the Linux machine and run the commands:
    cd /samba/morepretzels/
    ls -ltr​


The same contents get reflected in the Linux machine as well.

Mount on the client Linux with the steps :

  • Log in to the Linux client machine and become root with the command:
    su -
  • Install the packages cifs-utils, samba-client with the command:
    yum -y install cifs-utils samba-client
  • Create a mount point directory with the commands:
    cd /mnt
    mkdir sambashare​
  • Mount the /mnt/sambasharedirectory with the command:
    mount -t cifs // /mnt/sambashare/​ is the IP address of the Linux server machine.

  • Do not enter any password, press Enter to proceed.
  • To verify the mount point, run the command:
    df -h​


  • Check the contents of /mnt/sambashare, with the commands:
    cd /mnt/sambashare
    ls -l​


The same contents get reflected in the Linux client machine as well.

About Author :

Myself Debomita Bhattacharjee, an IT employee with 6+ years of experience in Software industry. My area of interest is Automation testing and Front End Development.

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions