I recommend to create a dedicated user for that share and specify it in force user(see docs).

Create a user (shareuser for example) and set the owner of everything in the share folder to that user:

adduser --system shareuser
chown -R shareuser /path/to/share

Then add force user and permission mask settings in smb.conf:

[myshare]
path = /path/to/share
writeable = yes
browseable = yes
public = yes
create mask = 0644
directory mask = 0755
force user = shareuser

Note that guest ok is a synonym for public.

Answer from yaegashi on Stack Exchange
Top answer
1 of 5
103

I recommend to create a dedicated user for that share and specify it in force user(see docs).

Create a user (shareuser for example) and set the owner of everything in the share folder to that user:

adduser --system shareuser
chown -R shareuser /path/to/share

Then add force user and permission mask settings in smb.conf:

[myshare]
path = /path/to/share
writeable = yes
browseable = yes
public = yes
create mask = 0644
directory mask = 0755
force user = shareuser

Note that guest ok is a synonym for public.

2 of 5
6

In the share settings in smb.conf, you'll need to specify the names of users and/or groups that are allowed to write to the share, using a write list = ... line.

Example:

[myshare]
...
write list = my_linux_username

Then you'll need to use the smbpasswd command to set up a password to authenticate my_linux_username for Samba:

sudo smbpasswd -a my_linux_username

This step is necessary because the standard system passwords in /etc/shadow are hashed in algorithms that are incompatible with the password hash algorithms used in the SMB protocol. When a client sends a SMB authentication packet, it includes a hashed password. It can only be compared to another password hash that uses the same algorithm.

(Very, very old instructions from the previous millennium may recommend disabling password encryption in Samba, and using certain registry hacks to allow Windows to emit unencrypted passwords to the network. This advice is obsolete: those registry hacks may no longer work in current versions of Windows, and allow anyone who can monitor your network traffic to trivially capture your password.)


There's one more thing you may have to do client-side. When your Windows client system is joined to an Active Directory domain and you're logged in with an AD account, it automatically prefixes all unqualified usernames with the name of the AD domain of the user, i.e. you will be authenticating as AD_DOMAIN\your_username, not just your_username.

If you are logged in with a local account (or your client system is not joined to an AD domain), Windows may automatically prefix the username with the client hostname unless you specify another domain name.

To successfully log in to a stand-alone Samba server from a stand-alone Windows client, you may have to specify your username as SAMBA_SERVER_HOSTNAME\your_username.

Otherwise Samba will see the username as WINDOWS_CLIENT_HOSTNAME\your_username, conclude that it has no way to verify any users belonging to domain named WINDOWS_CLIENT_HOSTNAME, and will reject the login.

(Newer versions of Samba may have a built-in check for this specific situation, and they might allow you access nevertheless. But this is basically how SMB authentication works "under the hood", and if you need to deal with old versions of Samba, it might be useful still.)

🌐
Server Fault
serverfault.com › questions › 1155891 › how-to-chown-a-directory-on-a-mounted-samba-share
linux - How to chown a directory on a mounted samba share? - Server Fault
//<serverip>/<nameofshare> /home/user -o nofail,x-systemd.device-timeout=15s,vers=3.11,user=<sambauser>,uid=<clientuser>,gid=<clientuserprimarygroup>,cifsacl,credentials=/path/to/cred 0 0 · On this mounted share I want to create a directory foo and chown so it belongs to user:group bar:bar.
🌐
Super User
superuser.com › questions › 1619046 › samba-shares-are-accessible-only-for-a-specific-user-set-by-chown
linux - Samba shares are accessible only for a specific user set by chown - Super User
January 19, 2021 - It only works when ownership is given to the samba user (shared) by running chown -R shared:sambasecure /mnt/Backup. I'm running CentOS 8, SELinux enabled.
🌐
Linux Mint Forums
forums.linuxmint.com › board index › main edition support › beginner questions
Samba Sharing [SOLVED] - Linux Mint Forums
sudo chown :nogroup /export/share1 ** Set the setgid bit so that all new files and folders inherit that group and allow write access to that group:
🌐
SambaWiki
wiki.samba.org › index.php › Setting_up_a_Share_Using_Windows_ACLs
Setting up a Share Using Windows ACLs - SambaWiki
June 26, 2024 - To share the /srv/samba/Demo/ directory using the Demo share name: ... To enable accounts other than the domain user Administrator to set permissions on Windows, grant Full control (rwx) to the user or group you granted the SeDiskOperatorPrivilege privilege. For example (if using the 'ad' backend): # chown root:"Unix Admins" /srv/samba/Demo/ # chmod 0770 /srv/samba/Demo/
🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-set-up-a-samba-share-for-a-small-organization-on-ubuntu-16-04
How To Set Up a Samba Share For A Small Organization on Ubuntu 16.04 | DigitalOcean
May 11, 2018 - sudo chown admin:sambashare /samba/ everyone/ sudo chmod 2770 /samba/ everyone/ sudo smbpasswd -a admin · sudo smbpasswd -e admin · In addition to creating the admin user, let’s create a group called admins to make the management of the server easier. With read and write permissions to ...
🌐
Jaytaala Confluence
confluence.jaytaala.com › display › TKB › Create+samba+share+writeable+by+all,+group,+or+only+a+user
Create samba share writeable by all, group, or only a user - Tech Knowledge Base - jaytaala.com Confluence
August 25, 2020 - This guide covers how to create ... we will call it 'shareuser') and set the folder (to share) to be owned by this user. useradd --system shareuser chown -R shareuser /media/share...
🌐
Arch Linux Forums
bbs.archlinux.org › viewtopic.php
[SOLVED] Can't write to Samba share on client without chown / Newbie Corner / Arch Linux Forums
I have set up a Samba share on my server that only allows users with the name "smbuser" and the group "smbgroup" to access the share. Said user and group exist on the server. The issue I am having is that on any client machine, the share cannot be written to unless I use `chown myuser -R /mnt/my-share` or sudo privileges.
Find elsewhere
🌐
45Drives
knowledgebase.45drives.com › home › kb450435 – setting up local user access smb shares
KB450435 - Setting up Local User Access SMB Shares - 45Drives Knowledge Base
October 17, 2025 - The directory must be set to 770 by doing chmod 770 /path/to/share for permissions, and the owner user/group is set as root:smbgroup by doing chown root:smbgroup where smbgroup is a local group that we have any local user attempting to connect ...
🌐
Arch Linux Forums
bbs.archlinux.org › viewtopic.php
Unable to change ownership on mounted samba share folder / Newbie Corner / Arch Linux Forums
November 15, 2022 - These shouldn't matter since from the perspective of jellyfin your samba share is local. These NetworkManager messages are more likely to be relevant for the clients you'll eventually connect. Online · d.ALT · Member · Registered: 2019-05-10 · Posts: 959 · jddoxtator wrote: d.ALT wrote: Could you go with this?: - in your smb.conf set force user = jellyfin - add jellyfin user to SAMBA users: https://wiki.archlinux.org/title/Samba#Adding_a_user - chown -R jellyfin: /video ·
🌐
Samba
samba.org › samba › docs › using_samba › ch09.html
Samba
# mkdir /home/METRAN # chmod 755 /home/METRAN # mkdir /home/METRAN/linda # chown 'METRAN\linda:METRAN\Domain Users' /home/METRAN/linda # chmod 700 /home/METRAN/linda · One side effect of creating the home directories is that if the Samba server is configured with a [homes] share, the domain users can see and access their home directories through Samba's file sharing.
🌐
OneUptime
oneuptime.com › home › blog › how to configure samba share permissions on ubuntu
How to Configure Samba Share Permissions on Ubuntu
March 2, 2026 - # Create the share directory sudo mkdir -p /srv/samba/department # Set ownership: owned by root, group access for the 'finance' group sudo chown root:finance /srv/samba/department # Set permissions: # Owner (root): rwx # Group (finance): rwx ...
🌐
SambaWiki
wiki.samba.org › index.php › Setting_up_a_Share_Using_POSIX_ACLs
Setting up a Share Using POSIX ACLs - SambaWiki - Samba.org
June 16, 2023 - For example, to set the owner of the /srv/samba/Demo/ directory to root, grant read and write permissions to the owner and the Domain Users group, and deny access to all other users, enter: # chmod 2770 /srv/samba/Demo/ # chown root:"Domain Users" /srv/samba/Demo/
🌐
Ubuntu
documentation.ubuntu.com › server › how-to › samba › share-access-controls
Share access controls - Ubuntu Server documentation
2 weeks ago - To match the Samba configuration ... owned by the username “melissa”. Enter the following in a terminal: $ sudo chown -R melissa /srv/samba/share/ $ sudo chgrp -R sysadmin /srv/samba/share/ $ sudo setfacl -R -m g:qa:rx ...
🌐
Medium
medium.com › @AustinNewtonTech › creating-a-samba-share-with-the-linux-command-line-ef5a69cb1a81
Creating a Samba Share With the Linux Command Line. | by Austin Newton | Medium
July 28, 2023 - sudo chown <YourUsername> /home/<YourUsername>/<YourFolderName> To find your Linux Box’s IP address, we just simply enter the command: ... The IP address following inet is what we want to remember.
🌐
CubePath
cubepath.com › docs › storage-management › samba-configuration-for-file-sharing
Samba Configuration for File Sharing: Complete Cross-Platform Setup Guide - CubePath Docs | CubePath
January 11, 2026 - # Public share (everyone can access) sudo chmod 777 /srv/samba/public sudo chown nobody:nogroup /srv/samba/public # Shared directory (group access) sudo chmod 2775 /srv/samba/shared sudo chown root:sambashare /srv/samba/shared # Department shares ...
Top answer
1 of 2
4

Edit the samba configuration file.

sudo nano /etc/samba/smb.conf

Add this to the end of the file:

[Public Directory]
comment = Contents are read/write by all.
path = /home/user/directory-to-be-shared
read only = no
guest ok = yes
create mask = 0666
force create mode = 0666
directory mask = 0777
force directory mode = 0777

Then restart samba.

sudo service smbd restart

Notes:

  1. The string within brackets (Public Directory in the example above) is what users will see when accessing the shared folder from other systems.
  2. Files created within this directory by users on other systems will be owned by nobody:nogroup, with read and write permissions for owner, group, and other.
  3. Directories created in this directory by users on other systems will be owned by nobody:nogroup, with read, write, and directory traversal permissions for owner, group, and other.
  4. The masks and modes in the configuration file apply to files and directories created by users on other systems. These masks and modes are ignored when creating files as a user on the server. Or, to put it another way, if you are user on the server, make sure that each file and directory that you create within /home/user/directory-to-be-shared has 666 and 777 permissions respectively.
  5. If you have enabled a firewall on the server, you will need to open port 445 for tcp. For example, if you use ufw (uncomplicated firewall) to configure the firewall:

    sudo ufw allow in 445/tcp
    sudo ufw reload
    sudo ufw status verbose
    
2 of 2
2

It's not clear to me if you want a share accessible to everyone or only a group of client users so this is a template for the latter.

Note: This will only work as described if the default umask of your system is 0002 so it will not work for Ubuntu Desktop 17/18 but it will work for Xubuntu Desktop and Ubuntu Server.

In this template it is required that all users you want to have access become members of the "users" group. It will assign the setgid bit on the shared directory and any future subdirectories which forces anything new added to them to inherit the group of it's parent folder.

sudo mkdir /path
sudo chown root:users /path
sudo chmod 2775 /path

The share would look like this:

[UsersShare]
path = /path
valid users = @users
force group = users
read only = no
create mask = 0664
force directory mode = 2775

When bob - who was made a member of the "users" group - logs in with his samba username/password and adds a file to the [UsersShare] share it will have owner = bob, group = users, mode = 664 files / 2775 folders.

All other client users who are members of the users group who sign in will have full access to whatever bob did.

Any local users - those on the server itself - who add or modify files who are also members of the users group will all have the same ability and newly created files/folders will have the same 664/2775 mode and all will have as group: "users". The one exception to all this is root - as in when you use sudo - since it's default umask is 022 unlike a regular user his files will inherit the "users" group but will have a mode of 644.

If you truly want a pure public share where everyone has access replace "valid users = @users" with "guest ok = yes". For this to work locally on the server you would still need to add those users to the "users" group.