The cart is empty

Samba server stands as one of the most popular tools for file and printer sharing across different operating systems, including Windows, Linux, and MacOS. In this article, we'll walk through the step-by-step process of configuring a Samba server on CentOS 7 for file sharing within a local network.

Installing Samba Server Before diving into configuration, it's necessary to install the Samba server. This can be achieved using the following commands in the terminal:

  1. Begin by updating the system:
    sudo yum update
    ​
  2. Install Samba server:
    sudo yum install samba samba-client samba-common
    ​

 

Configuring Samba

After installation, it's time to configure the Samba server itself.

  1. Basic Configuration

    • First, let's back up the original configuration file:
      sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.backup
      ​
    • Open the configuration file in an editor:
      sudo nano /etc/samba/smb.conf
      ​
    • In the file, set up the basic [global] section where we define the workgroup name and server description. For example:
      [global]
      workgroup = WORKGROUP
      server string = Samba Server %v
      netbios name = centos7
      security = user
      map to guest = bad user
      dns Proxy = no
      ​
  2. Adding Shared Directories

    • Now, let's add a section for the shared directory to the configuration file. For instance, to share a directory named shared within a user's home directory:
      [shared]
      path = /home/username/shared
      writable = yes
      browsable = yes
      guest ok = yes
      read only = no
      ​
    • Save the file and close the editor after making the changes.

 

Managing Samba Users To access the shared directories, we can create specific Samba users or use existing system users.

  1. Adding a Samba user:
    sudo smbpasswd -a username
    ​
  2. Enabling the user:
    sudo smbpasswd -e username
    ​

 

Starting and Testing the Samba Server

After configuration, start the Samba server:

sudo systemctl start smb nmb
sudo systemctl enable smb nmb

Test the configuration:

smbclient -L \\centos7 -U username

 

At this point, the Samba server on CentOS 7 should be fully functional and ready for use. File sharing within the local network should be straightforward and efficient. If needed, don't forget to make further adjustments to the configuration file to tailor it to your specific requirements.