Skip to content
Follow
Ubuntu Linux

How to Create a Private Samba Share on Ubuntu 24.04

Richard
Written by
Richard
Feb 26, 2025 Updated Jul 13, 2026 4 min read
How to Create a Private Samba Share on Ubuntu 24.04
How to Create a Private Samba Share on Ubuntu 24.04

Creating a private Samba share on Ubuntu 24.04 lets you securely share files and printers with specific users over a network. Samba is free software that lets Linux and Windows computers talk to each other for file and printer sharing.

You set up a Samba server and give unique usernames and passwords to anyone you want to grant access. This gives you control over who sees your shared folders and files, protecting important data on your home or small office network.

For example, you can even tell your Samba share to only allow connections from certain computers on your network, adding an extra layer of security.

⚡ Quick Answer

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

📝Good to Know
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.

🐧Bash / Shell
sudo apt update
sudo apt install samba

Create a share folder

Creating a private Samba share folder on Ubuntu starts with making a new folder and a special group for users. This group acts like a guest list, deciding who can see and use the private folder, ensuring only approved people can connect.

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.

🐧Bash / Shell
sudo groupadd smbgroup

Then, create the private share and adjust the permission so only group members have access.

🐧Bash / Shell
sudo mkdir /home/private
sudo chgrp smbgroup /home/private
sudo chmod 770 /home/private

Configure Samba

You configure your private Samba share on Ubuntu by editing the main Samba settings file, located at /etc/samba/smb.conf. It’s crucial to back up this file first, using the command `sudo cp /etc/samba/smb.conf`, so you can easily restore it if any changes cause problems.

Samba default configuration file is at [/etc/samba/smb.conf].

First, create a backup before editing it.

🐧Bash / Shell
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak

Then edit the file and adjust the highlighted settings below.

🐧Bash / Shell
sudo nano /etc/samba/smb.conf

Adjust the settings below.

💻Code
#======================= 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.

🐧Bash / Shell
sudo systemctl restart smbd

Create Samba users

To create Samba users for your private share, you set up specific accounts and add them to the group you created. For existing accounts, you create a Samba password using `sudo smbpasswd -a sambauser` and then add that user to your Samba group to grant them access.

If you have an existing account, create a smbpasswd for the account.

🐧Bash / Shell
sudo adduser sambauser
sudo smbpasswd -a sambauser

Type and configure a new password for the account.

⚠️Warning
Finally, add the user account to the Samba group account created above.
🐧Bash / Shell
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

You map your private Samba share on Windows using the ‘Map network drives’ tool in File Explorer. This connects you to your shared folder by entering the server’s name and the share’s name, and then you’ll enter your Samba account details when prompted.

Right-click the Network folder in File Explorer and select “Map network drives.”

Map network drives Windows 11
Map network drives Windows 11

Enter the server name followed by the share name.

💻Code
\srv1.example.comshare
Map network drives Windows 11 shares
Map network drives Windows 11 shares

When prompted, enter the Samba account created above.

Samba user access prompt
Samba user access prompt

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

Map network drives Windows 11 complete
Map network drives Windows 11 complete

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.
section, specifying the path, security settings, and valid users to restrict access to your Samba member group.”]

Was this guide helpful?

Was this helpful?
Richard

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.

📚 Related Tutorials

Map Network Drives with PowerShell in Windows 11
Windows Map Network Drives with PowerShell in Windows 11
How to Add or Remove Favorites in Windows 11 File Explorer
Windows How to Add or Remove Favorites in Windows 11 File Explorer
How to Use Access Keys in Windows 11 File Explorer
Windows How to Use Access Keys in Windows 11 File Explorer
How to Change File Explorer Layout in Windows 11
Windows How to Change File Explorer Layout in Windows 11

No comments yet — be the first to share your thoughts!

Leave a Comment

Your email address will not be published. Required fields are marked *