Categories: CentOSLinuxShell

How to Install and Configure Samba on CentOS 8

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

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

# systemctl enable smb

# systemctl start smb

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

# systemctl status smb

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

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

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

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

# systemctl restart smb

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

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

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

Reload the firewall using this command:

# firewall-cmd - - reload

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.

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

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

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:

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.

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.

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. You can reach Karim on LinkedIn

Recent Posts

How to Install Magento 2 on AlmaLinux

Magento is a free and open-source e-commerce platform written in PHP. It is simple, easy…

1 year ago

How to Install ISPConfig Hosting Control Panel with Apache Web Server on Ubuntu 24.04

ISPConfig is an open-source control panel that allows users to manage multiple servers from a…

1 year ago

How to Test your Email Server (SMTP) Using the Telnet Command

As a Linux administrator, you may find it necessary to troubleshoot or test your Simple…

1 year ago

Managing Network Interfaces and Settings on Ubuntu 24.04 with nmcli

Ubuntu 24.04, like many modern Linux distributions, relies on the NetworkManager for managing network connections.…

2 years ago

Using Restic Backup on Ubuntu 24.04

Restic is a modern, open-source backup program designed for efficiency, security, and simplicity. It enables…

2 years ago

Installing phpMyAdmin on Rocky Linux 9 and Securing it with Let’s Encrypt SSL

phpMyAdmin is a popular free tool written in PHP intended to administer MySQL and MariaDB…

2 years ago