How to Create a Private Samba Share on Ubuntu 24.04
A private Samba share on Ubuntu 24.04 lets you safely share files between Linux and Windows computers on your home network using specific usernames and passwords. Samba is free software that bridges the gap between different operating systems so they can talk to each other.
You create a secure folder on your Ubuntu 24.04 machine and lock it down so only trusted people can open it. This stops random people on your local network from seeing your personal files and sensitive data.
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
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
Creating a private Samba share folder on Ubuntu starts by making a new directory and setting up a dedicated user group for access control. This group acts like a guest list to make sure only approved people can connect to your private folder.
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
Configuring your private Samba share on Ubuntu requires editing the main settings file located at /etc/samba/smb.conf. Always back up this file first so you can restore your original settings if a mistake breaks your connection.
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
Creating Samba users for your private share involves setting up specific login accounts and adding them to your restricted user group. You must assign a password using the smbpasswd tool so authorized people can log in from other computers.
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.
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
Mapping your private Samba share on Windows uses the map network drive tool in File Explorer to connect your PC to the Linux folder. You enter your server address and sign in with your Samba account credentials to access the files.
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!