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.
- 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.
non-root sudo useror 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:
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:
- Open File Explorer on your Windows machine.
- In the address bar, enter the IP address or hostname of your Rocky Linux machine:
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.
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.