How to install and configure Samba on CentOS 8

Samba is a free open source implementation of the Windows SMB protocol (CIVFS) that allows us to easily and easily share files, folders, and printers between Linux and the Windows operating system. It uses TCP port 445.

In this guide, I’ll show you how to install and configure Samba on CentOS 8.

Install Samba packages

To install samba packages on CentOS 8, open a terminal and enter the following command:

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

After installing 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 check the status of the Samba service with the following command:

                      # systemctl status smb

Check Samba Service Status

Samba setup

Once the installation is complete, it’s time to configure Samba. But before doing that, make a copy of the original config file using the following command:

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

Samba configuration file backup

The next step is to create a folder that needs to be shared, I name this folder. general

Create directory for file sharing Advertising

After creating the folder, navigate to the config file and configure Samba and resolve the newly created directory to be shared as shown in the figure.

                      # vim /etc/samba/smb.conf

Create new samba config 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 this user a member of that group so that he 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 group Vitux , confirm that the user is added to the group or not? To do this, use the following command:

                      # grep ‘vitux’ /etc/group

Create group for samba file share

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

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

Configure CentOS Firewall

Reload the firewall with this command:

                      # firewall-cmd - - reload

Apply firewall rules

Accessing the Samba folder from a Windows computer

To access samba share from Windows, click Windows Key + R launch Run Dialogue. Enter IP address or hostname and press To come in

Connect to Linux file server from Windows

You will be prompted for your samba credentials, enter your credentials and click OK

Login details

After a successful login, the public directory becomes available and available for use, as shown in the figure:

Sharing a folder between Linux and Windows

Accessing the Samba folder from a Linux machine

To access Samba shares from another Linux machine, open GNOME file manager and click Connect to server as it shown on the picture:

Connect to Samba share from Linux

Enter the IP address of your Samba server and click Connect. You will be prompted to enter your Samba credentials to use Public directly, enter your Samba credentials, you can now see Are common folder is available.

Shared folder in Linux


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

How to install and configure Samba on CentOS 8

Related Posts