VOOZH about

URL: https://thenewstack.io/samba-network-shares-for-rhel-based-linux-distributions/

⇱ Samba Network Shares for RHEL-Based Linux Distributions - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2024-02-25 06:00:27
Samba Network Shares for RHEL-Based Linux Distributions
Linux / Networking / Operations

Samba Network Shares for RHEL-Based Linux Distributions

At some point, you're going to have a Linux server that includes directories that clients need to access from your network. Your best bet for this is Samba.
Feb 25th, 2024 6:00am by Jack Wallen
👁 Featued image for: Samba Network Shares for RHEL-Based Linux Distributions
Feature clip by Mohamed Hassan from Pixabay.

At some point, you’re going to have a Linux server that includes directories that various users, developers, admins, or clients need to access from your network. If you depend on Linux, your best bet for this is Samba.

Samba is the Linux implementation of the SMB protocol and has been used for years to make sharing both directories and printers across a network, regardless if you want to access the files using Linux or Microsoft Windows. Samba can be installed on most any Linux distribution, but whether you use an Ubuntu or RHEL-based distribution will determine how you achieve success.

I want to show you how to install and configure a Samba share on Rocky Linux, but the process will work for the likes of Red Hat Enterprise Linux, AlmaLinux, OracleLinux, and even Red Hat’s CentOS Stream.

What You’ll Need

To make this work, you’ll need a running instance of Rocky Linux (or one of the distributions mentioned above) and a user with sudo privileges. Of course, you’ll also need a network connection and clients on the same network (that can connect to the Samba server).

That’s it. Let’s get to the sharing.

Installing Samba

The first thing to do is install Samba. Log into your Rocky Linux instance and first make sure everything is up to date with the command:

sudo dnf update

When the update completes, install the necessary Samba components with the command:

sudo dnf install samba samba-common samba-client -y

Once the installation completes, you can then start and enable the Samba service with the command:

sudo systemctl enable --now smb

You can verify the service is running with the command:

sudo systemctl status smb

You should see it listed as active running.

Creating Your First Samba Share

We’re going to create a share in the /srv directory and name it data. Create this directory with the command:

sudo mkdir /srv/data

Of course, you can name that directory anything you like.

After creating the directory, you’ll then need to change the ownership and permission with the following two commands:

sudo chmod -R 755 /srv/data
sudo chown nobody:nobody /srv/data

The first command recursively sets the permissions of /srv/data to 755, which means the owner can do anything with the file or directory, and all other users can read and execute it but not alter the contents. The second command changes the user and group ownership to nobody.

Next, we must make SELinux aware of our changes (so we can keep the security system in enforcing mode) with the command:

sudo chcon -t samba_share_t /srv/data

So far so good.

Configuring the Samba Share

Samba shares are configured in the smb.conf file. Before you open the file, know that it can be a bit overwhelming. Don’t worry because everything we’re going to do is an addition to the bottom of the file and you won’t have to comb through the file to edit it line by line.

Open the file for editing with the command:

sudo nano /etc/samba/smb.conf

We’re going to create a share that configures the following:

  • Set the path to /srv/data
  • Make it browsable to your network
  • Make it writable
  • Prevent guest access
  • Set read-only mode to no
  • Force the 0666 create mode so users can create files
  • Force the 0777 directory mode so users can create directories
  • Make it browseable to our network

The configuration block for this looks like:

[Public]
path = /srv/data
browsable = yes
writable = yes
guest ok = no
read only = no
create mask = 0666
directory mask = 0777

Save and close the file.

Restart Samba with the command:

sudo systemctl restart smb

Opening the Firewall for Samba

Before anyone can access the share, you must first make some adjustments to your firewall. First open the necessary ports with the command:

sudo firewall-cmd --add-service=samba --zone=public --permanent

Reload the firewall (so the changes take effect) with the command:

sudo firewall-cmd --reload

Your Samba share is up and running. However, there’s one more problem to resolve. Even though you might have users registered on your Rocky Linux server, Samba isn’t aware of them. Fortunately, there’s a command for that. The problem is that, in order for all of your users to access the share you have to set a Samba password for them. This password will be different than their standard user password.

So, say you have a user named “penguin” who needs access to the Samba share. First, give that user a Samba password with the command:

sudo smbpasswd -a penguin

You’ll be prompted for your sudo password and then to type/verify a Samba password for the user.

Once you’ve taken care of that, you then have to enable the user (sticking with our example above) for Samba which is done with a command like this:

sudo smbpasswd -e penguin

You will not be prompted for a password this time because the above command simply enables the user for Samba.

Now, the penguin user will have access to the Samba share. Of course, you’ll have to take the above steps for all users who need access to the Samba share.

And that’s all there is to create a Samba share on a RHEL-based Linux distribution. Enjoy all that sharing you’ll do across your network.

TRENDING STORIES
Jack Wallen is what happens when a Gen Xer mind-melds with present-day snark. Jack is a seeker of truth and a writer of words with a quantum mechanical pencil and a disjointed beat of sound and soul. Although he resides...
Read more from Jack Wallen
SHARE THIS STORY
TRENDING STORIES
The Linux Foundation, Microsoft, Oracle and Red Hat are sponsors of The New Stack.
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.