RHEL BasedRocky Linux

How To Install Samba on Rocky Linux 9

Install Samba on Rocky Linux 9

In this tutorial, we will show you how to install Samba on Rocky Linux 9. For those of you who didn’t know, Samba is a powerful and versatile open-source software that allows seamless file and printer sharing between Linux and Windows systems.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Samba on Rocky Linux 9 or RHEL-based.

Prerequisites

  • A server running one of the following operating systems: Rocky Linux 9.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for Samba.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Samba on Rocky Linux 9

Step 1. The first step is to update your system to the latest version of the package list. To do so, run the following commands:

sudo dnf update
sudo dnf upgrade

Step 2. Installing Samba on Rocky Linux 9.

 Once the system is updated, you can install Samba by running the following command:

sudo dnf install samba

Step 3. Configuring Samba.

Configuring Samba correctly is crucial for smooth file sharing. Let’s get started:

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

Open the Samba configuration file for editing using your preferred text editor:

sudo nano /etc/samba/smb.conf

In the configuration file, scroll down to the ‘[global]‘ section and make the following changes:

a. Define the workgroup name:

workgroup = YOUR_WORKGROUP_NAME

Replace ‘YOUR_WORKGROUP_NAME’ with your desired workgroup name, which should match the workgroup of your Windows machines.

b. Configure the network interfaces to which Samba will bind:

interfaces = lo enp0s3

Replace ‘enp0s3’ with the name of your network interface, if it differs from the default.

c. Set Samba to be accessible by everyone:

security = user
map to guest = Bad User

Save and exit the configuration file (Press ‘CTRL+X’, then ‘Y’, and ‘Enter’).

Step 4. Creating a Samba User.

Next, we’ll create a user account that will be used to access Samba shares:

sudo useradd -m username

Set a password for the new Samba user:

sudo smbpasswd -a username

You will be prompted to enter the password for the user.

Step 5. Creating a Shared Directory.

To share files with Windows clients, you need to create a directory and set the appropriate permissions:

Create a directory to be shared with Windows clients (replace ‘username’ with the Samba user you created earlier):

sudo mkdir /home/username/share

Set the appropriate permissions for the shared directory:

sudo chown -R username:username /home/username/share
sudo chmod -R 755 /home/username/share

Step 6. Testing Samba Configuration.

Before restarting the Samba service, it’s essential to check the configuration for syntax errors:

testparm

If there are no errors, you can proceed to restart the Samba service to apply the changes:

sudo systemctl restart smb
sudo systemctl enable smb

Step 7. Accessing Samba Share from Windows.

You’ve successfully configured Samba on your Rocky Linux 9 system. Now, let’s access the shared folder from a Windows machine:

  1. Open File Explorer on your Windows machine.
  2. In the address bar, enter the IP address or hostname of your Rocky Linux machine:
\\rocky_linux_ip_or_hostname

Replace ‘rocky_linux_ip_or_hostname’ with the actual IP address or hostname of your Rocky Linux machine.

If prompted, enter the Samba username and password you created earlier to access the shared folder.

Step 8. Troubleshooting Tips.

Setting up Samba can sometimes be challenging, but don’t worry. Here are some troubleshooting tips to help you overcome common issues:

  • Firewall Settings:

Ensure that the necessary ports (e.g., TCP 139, 445, UDP 137, 138) are open on both the server and client machines. Firewall settings may block Samba traffic, leading to connectivity issues.

  • SELinux:

If you’re using SELinux, it might interfere with Samba’s functionality. Use the following command to allow Samba to access files:

sudo setsebool -P samba_enable_home_dirs on
  • Check Log Files:

The log files (/var/log/samba/) can provide valuable information about any errors or issues encountered during Samba operations. Use them to diagnose and resolve problems.

Congratulations! You have successfully installed Samba. Thanks for using this tutorial for installing Samba on your Rocky Linux 9 system. For additional help or useful information, we recommend you check the official Samba website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button