How to Install Samba on RHEL-Based Linux Distributions

In this article we will try to teach you how to Install Samba on RHEL-Based Linux Distributions. Samba is a popular freeware program that allows end users to access and use files, printers, and other shared resources on a company’s intranet or the Internet. Often referred to as a network file system, Samba can be installed on a variety of operating system platforms including: Linux, the most popular UNIX platforms, OpenVMS and OS/2. Samba is based on the common client/server protocol Server Message Block (SMB) and Common Internet File System (CIFS).

Using client software that also supports SMB/CIFS (such as most Microsoft Windows products), an end user sends a series of client requests to the Samba server on another computer to view that computer’s files to open, access a shared printer, or access other resources. The Samba server on the other computer responds to each client request, granting or denying access to its shared files and resources.

Linux is an open-source operating system like other operating systems like Microsoft Windows, Apple Mac OS, iOS, Google Android, etc. An operating system is software that enables communication between computer hardware and software. It conveys inputs to be processed by the processor and brings outputs to the hardware for display. This is the basic function of an operating system. Although it performs many other important tasks, we won’t talk about them. Below we have mention the steps to Install Samba on RHEL-Based Linux Distributions.

How to Install Samba on RHEL-Based Linux Distro

Install Samba in Linux

Step 1: To get started out with Samba, install the Samba core packages including the client package:

$ sudo dnf install samba samba-common samba-client

The command installs the packages specified along with the dependencies as displayed on the output. After the installation is complete, you will get a summary of all the packages that have been installed.

Create and Configure Samba Shares

After all the Samba packages have been installed, the next step is to configure the Samba shares. A Samba share is simply a directory shared by client systems on the network.

Step 1: Here, we are going to create a samba share called /data in the /srv/tecmint/ directory path.

$ sudo mkdir -p /srv/tecmint/data

Step 2: Next, we will assign permissions and ownerships as follows.

$ sudo chmod -R 755 /srv/tecmint/data$ sudo chown -R nobody:nobody /srv/tecmint/data$ sudo chcon -t samba_share_t /srv/tecmint/data

Step 3: Next, we are going to make some configurations in the smb.conf configuration file which is Samba’s main configuration file. But before we do so, we will back up the file by renaming it with a different file extension.

$ sudo mv /etc/samba/smb.conf /etc/samba/smb.conf.bak

Step 4: Next, we are going to create a new configuration file.

$ sudo vim /etc/samba/smb.conf

Step 5: We will define policies on who can access the samba share by adding the lines shown in the configuration file.

[global]workgroup = WORKGROUPserver string = Samba Server %vnetbios name = rocky-8security = usermap to guest = bad userdns proxy = nontlm auth = true

 

[Public]path = /srv/tecmint/databrowsable =yeswritable = yesguest ok = yesread only = no

Step 6: Save and exit the configuration file.

Step 7: To verify the configurations made, run the command:

$ sudo testparm

Step 8: Next, start and enable Samba daemons as shown.

$ sudo systemctl start smb$ sudo systemctl enable smb$ sudo systemctl start nmb$ sudo systemctl enable nmb

Step 9: Be sure to confirm that both the smb and nmb daemons are running.

$ sudo systemctl status smb$ sudo systemctl status nmb

Accessing Samba Share from Windows

Step 1: Thus far, we have installed samba and configured our samba share. We are now ready to access it remotely. To do this on a Windows client, press the Open Windows command Run dialog.

Step 2: In the textfield provided, enter the samba server’s IP address as shown:

\server-ip

The following window labeled ‘Public’ will pop up. Remember, this is the directory that points to our samba share in the /srv/tecmint/data directory.

Step 3: Currently, our directory is empty as we have not created any files. So, we will head back to our terminal and create a few files in the samba share directory.

$ cd /srv/tecmint/data$ sudo touch file{1..3}.txt

Step 4: Now, we will navigate to the ‘Public‘ folder where the files we created earlier on will be displayed.

Perfect. We have successfully managed to access our samba share. However, our directory is accessible to anyone and everybody can edit and delete files at will, which is not recommended especially if you plan to host sensitive files.

Secure Samba Share Directory

Step 1: First, we will create a new samba user.

$ sudo useradd smbuser

Step 2: Next, we will configure a password for the samba user. This is the password that will be used during authentication.

$ sudo smbpasswd -a smbuser

Step 3: Next, we will create a new group for our secure samba share and add the new samba user.

$ sudo groupadd smb_group$ sudo usermod -g smb_group smbuser

Step 4: Thereafter, create yet another samba share which will be securely accessed. In our case, we have created another directory in the same path as the

$ sudo mkdir -p /srv/tecmint/private

Step 5: Then configure the file permissions for the samba share

$ sudo chmod -R 770 /srv/tecmint/private$ sudo chcon -t samba_share_t /srv/tecmint/private$ sudo chown -R root:smb_group /srv/tecmint/private

Step 6: Once again, access the Samba configuration file.

$ sudo vim /etc/samba/smb.conf

Step 7: Add these lines to define to secure samba share.

[Private]path = /srv/tecmint/privatevalid users = @smb_groupguest ok = nowritable = nobrowsable = yes

Step 8: Save the changes and exit.

Step 9: Finally, restart all the samba daemons as shown.

$ sudo systemctl restart smb$ sudo systemctl restart nmb

When you access your server this time, you’ll notice an additional “Private” folder. To access the folder, you must authenticate yourself with the Samba user credentials. Enter the username and password of the user you created in the previous step and click OK.

Accessing Samba Share from Linux Client

Step 1: To access the share from a Linux client, first, ensure that the Samba client package is installed.

$ sudo dnf install samba-client

Step 2: Then use the smbclient command as follows

# smbclient ‘2.168.43.121private’ -U smbuser

Final Words

We hope our article on how to Install Samba on RHEL-Based Linux will help you and resolve all your problems. Samba is an open-source software suite that runs on Unix/Linux distros but can communicate with Windows clients like a native application. So Samba is able to provide this service by using the Common Internet File System (CIFS). If you want to know how to install Samba on Linux then follow the steps mentioned above.

I hope you understand this article, How to Install Samba on RHEL-Based Linux Distributions.

Editorial Staff
Editorial Staffhttps://www.bollyinside.com
The Bollyinside editorial staff is made up of tech experts with more than 10 years of experience Led by Sumit Chauhan. We started in 2014 and now Bollyinside is a leading tech resource, offering everything from product reviews and tech guides to marketing tips. Think of us as your go-to tech encyclopedia!

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Related Articles

Best Telemedicine Software: for your healthcare practice

Telemedicine software has transformed my healthcare visits. It's fantastic for patients and doctors since they can obtain aid quickly. I...
Read more
I love microlearning Platforms in today's fast-paced world. Short, focused teachings that engage me are key. Microlearning platforms are great...
Think of a notebook on your computer or tablet that can be changed to fit whatever you want to write...
As of late, Homeschool Apps has gained a lot of popularity, which means that an increasing number of...
From what I've seen, HelpDesk software is essential for modern businesses to run easily. It's especially useful for improving customer...
For all of our important pictures, stories, and drawings, Google Drive is like a big toy box. But sometimes the...