The cart is empty

Samba is an open-source software that enables file and printer sharing between different operating systems, including Linux and Windows. This article outlines a step-by-step guide to configuring a Samba server on CentOS 7 to facilitate file sharing between Linux and Windows systems.

System Preparation

Before configuring the Samba server, it's essential to ensure that your system is up to date. Run the following commands in the terminal:

sudo yum update
sudo yum upgrade

Installing Samba

The first step is to install the Samba software. This can be done using the following command:

sudo yum install samba samba-client samba-common

After installation, check if the Samba services are running and set to start automatically upon system boot:

sudo systemctl start smb nmb
sudo systemctl enable smb nmb

Configuring Samba

Samba configuration is performed by editing the /etc/samba/smb.conf file. Before editing, it's a good practice to create a backup of the original file:

sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.backup

Open the /etc/samba/smb.conf file in an editor:

sudo nano /etc/samba/smb.conf

And add the following section at the end of the file, which is a basic configuration for sharing:

[sharedfolder]
   path = /srv/samba/sharedfolder
   writable = yes
   browsable = yes
   guest ok = yes
   create mask = 0775
   directory mask = 0775

In this configuration, [sharedfolder] is the name of the shared folder that will appear on the network. path is the path to the local directory on the server to be shared. Other directives determine who can use the folder and how.

After saving and closing the file, restart the Samba services:

sudo systemctl restart smb nmb

Firewall Configuration

It's important to ensure that the firewall allows access to the Samba share. Use the following commands:

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

Creating the Shared Folder

If the path specified in the configuration file doesn't exist yet, create it and set the necessary permissions:

sudo mkdir -p /srv/samba/sharedfolder
sudo chmod -R 0775 /srv/samba/sharedfolder
sudo chown -R nobody:nogroup /srv/samba/sharedfolder

Accessing the Samba Share from Windows

On Windows, open File Explorer, enter \\server_ip_address\sharedfolder in the address bar, and press Enter. You should see the contents of the shared folder.

 

You should now have a fully functional Samba server enabling file sharing between Linux and Windows systems on CentOS 7. For more advanced configurations and security measures, it's recommended to refer to the official Samba documentation.