Samba is a free and open-source implementation of the Windows SMB (CIVFS) protocol that allows us to share files, folders, and printers between Linux and Windows Operating System simply and seamlessly.

In this tutorial, I will show you how to install and configure Samba on CentOS 8.

Install Samba packages

To install samba packages in centOS 8, open up the terminal and type the following command:

# dnf install –y samba samba-common samba-client

Install Samba server and client

After installing the Samba Start and enable the samba service with the following command:

# systemctl enable smb

Enable SMB service

# systemctl start smb

Start Samba service

You can verify the Samba Service Status with the following command:

# systemctl status smb

Check status of Samba service

Configuring Samba

After the installation is completed, it’s time to configure Samba. But before that, make a copy of Original configuration file using the following command:

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

back up Samba configuration file

Next Step, is to create a folder which has to share, I am giving the name of this folder common.

Create directory to share files

After creating the folder, let’s go to the configuration file and Configure Samba and allow the newly created directory which has to share as shown in the figure.

# vim /etc/samba/smb.conf

Create new samba configuration file

After that Restart the Samba Services, using the following command:

# systemctl restart smb

Restart Samba service

Now create a user and Group and make that user member of that group so they can use the samba service, using the following commands:

# useradd user1
# passwd user1
# smbpasswd –a user1
# groupadd vitux
# usermod –aG vitux user1

After adding user1 to group vitux, confirm that the user is added to a group or not? For this use following command:

# grep ‘vitux’ /etc/group

Create group for samba file share

To allow samba services to access from other machines as well, add a firewall rule as shown below:

# firewall-cmd - - add-service=samba - - permanent

Configure CentOS Firewall

Reload the firewall using this command:

# firewall-cmd - - reload

Apply Firewall rules

Accessing the Samba Folder from Windows Machine

To access samba share from windows press Windows Key+ R to launch Run Dialogue. Enter the IP address or Hostname and press Enter.

Connect to Linux file server from Windows

It will prompt you to enter samba credentials, enter your credentials, and press OK.

Login details

After successfully logged in, a public directory is accessible and available for use as shown in the figure:

Share folder between Linux and Windows

Accessing the Samba Folder from Linux Machine

To access the Samba shares from other Linux machine, open the GNOME file manager and click on Connect to Server as shown in the figure:

Connect to Samba share from Linux

Provide your Samba Server IP address and click on Connect, you will be prompted to enter your Samba credentials to use Public directly, provide samba credentials now you can see Common folder is accessible.

Shared Folder on Linux

Conclusion

In this tutorial, we learned how to configure a Samba Server on CentOS 8. We created a shared directory that is accessible over the network from Linux and Windows systems. We also saw how to configure the firewall so we can access the Samba file server from other machines.

How to Install and Configure Samba on CentOS 8
Avatar

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.