How to Create a Private Samba Share on Ubuntu 24.04
You create a private Samba share on Ubuntu 24.04 by setting up a Samba server to allow specific users to access shared files and printers securely.
Samba is an essential open-source software suite that bridges the gap between Linux/Unix and Windows systems, enabling seamless file and printer sharing via the SMB/CIFS protocol. This technology mirrors how Windows itself handles network file sharing.
By defining individual user accounts and their passwords, you gain precise control over who can access your network resources. This is crucial for safeguarding sensitive data on your home or small office network.
For instance, you can configure Samba to only permit access from specific IP addresses, adding another layer of security beyond just user authentication.
Install Samba using `sudo apt install samba`. Create a shared folder and group with `sudo mkdir /home/private`, `sudo groupadd smbgroup`, `sudo chgrp smbgroup /home/private`, and `sudo chmod 770 /home/private`. Configure `/etc/samba/smb.conf` with your share details, then restart Samba with `sudo systemctl restart smbd`.
Install Samba
To use Samba on Ubuntu, you must install its packages. It is not available on Ubuntu by default.
Run the command below to install Samba.
sudo apt update
sudo apt install samba
Create a share folder
To set up a private Samba share on Ubuntu, first create the folder you want to share and a special group for users who will access it.
The folder (private) below will be visible and accessible to members only requiring authentication.
But before that, create a Samba member group. This group will contain all the users who should have access to the private folder.
sudo groupadd smbgroup
Then, create the private share and adjust the permission so only group members have access.
sudo mkdir /home/private
sudo chgrp smbgroup /home/private
sudo chmod 770 /home/private
Configure Samba
Next, you’ll adjust the Samba configuration file, located at /etc/samba/smb.conf, to set up your private share, making sure to back it up first.
Samba default configuration file is at [/etc/samba/smb.conf].
First, create a backup before editing it.
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
Then edit the file and adjust the highlighted settings below.
sudo nano /etc/samba/smb.conf
Adjust the settings below.
#======================= Global Settings =======================
[global]
# Change this to the workgroup/NT-domain name your Samba server will part of
workgroup = WORKGROUP
# server string is the equivalent of the NT Description field
server string = %h server (Samba, Ubuntu)
#### Networking ####
# Uncomment and add your interface name
interfaces = 127.0.0.0/8 ens33
# Uncomment this to bind to the named interfaces and/or networks
bind interfaces only = yes
#======================= Share Definitions =======================
#
# Under share definitions, create your share with the folder above.
[Private]
# require authentication
security = user
# specify shared directory
path = /home/private
# allow all to write
writable = yes
# deny guest user (nobody)
guest ok = no
# allow only smbgroup members
valid users = @smbgroup
# smbgroup will inherit new files/directories
force group = smbgroup
# set all new files to members only
force create mode = 770
# set all new folers to members only
force directory mode = 770
# inherit permissions from parent folder
inherit permissions = yes
Save and exit the file.
Restart Samba.
sudo systemctl restart smbd
Create Samba users
Now, create the user accounts that will be used to log into your private Samba share, and add them to the Samba group you made earlier.
If you have an existing account, create a smbpasswd for the account.
sudo adduser sambauser
sudo smbpasswd -a sambauser
Type and configure a new password for the account.
Finally, add the user account to the Samba group account created above.
sudo usermod -aG smbgroup sambauser
Samba share is created. Users on the same network should be able to browse and locate the shared folder.
Map Samba shares on Windows
Windows computers can connect to your private Samba share by using the ‘Map network drives’ tool, entering the server and share name, and then your Samba login details.
Right-click the Network folder in File Explorer and select “Map network drives.”

Enter the server name followed by the share name.
\srv1.example.comshare

When prompted, enter the Samba account created above.

After that, the share should be mapped to your Windows machine.

That should do it!
Conclusion:
- Samba provides an effective way to share files and printers between Linux/Unix and Windows systems.
- Creating a private Samba share enhances security by restricting access to authorized users only.
- The installation and configuration of Samba on Ubuntu 24.04 ensures that only members of a specified group can access the shared resources.
- Users can easily map the Samba share on Windows, facilitating seamless access to shared files.
- Regular management of user accounts and permissions is crucial to maintaining the integrity and security of the shared environment.
Was this guide helpful?
About the Author
Richard
Tech Writer, IT Professional
Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.
No comments yet — be the first to share your thoughts!