How to Create a Samba Share with Custom Access Control Directory for Local Users

Abstract: Configure Samba to enforce specific file and directory permissions for local users by setting create mask, directory mask, and force create mode in smb.conf.

Created: 2026-10-03 by
To create a Samba share with custom access control for local users, you must configure the [global] section to ignore system ACLs and define default permission styles. Then, in your specific [share] definition, set create mask, directory mask, and force create mode to enforce strict file modes and ensure execute permissions are always applied as intended.

Understanding Access Control Requirements

By default, Samba often relies on the underlying POSIX permissions of the Linux filesystem. While this is secure, it can be cumbersome when managing complex user groups or when you need consistent permissions regardless of how files are created from different clients. For many homelab environments or small business setups, administrators prefer explicit control over file creation masks rather than relying solely on the system's discretionary access control lists (DAC). This approach allows you to decouple the network sharing layer from the OS-level permission inheritance. You can specify exactly what permissions new files and directories should have, ensuring that local users interacting with the share get the expected experience without needing root privileges to chmod every single file manually. This is particularly useful when dealing with applications that expect specific executable bits or read/write structures.

Configuring Global Samba Settings

The foundation of custom access control lies in the global configuration block. Before defining individual shares, you need to instruct Samba on how to handle permissions at a system level. Open your smb.conf file, typically located at /etc/samba/smb.conf, using a text editor like nano or vim. You will need to add or modify several directives under the [global] section. The most critical setting here is map archive. By default, Samba maps the Windows "Archive" attribute to the Unix "read-only" bit. Setting map archive = no prevents this automatic mapping, giving you cleaner control over write permissions. Additionally, you should address how Samba interacts with extended attributes. If your system uses ACLs extensively, you might want to use nt acl support = no if you are strictly managing permissions via Unix masks. However, for most modern setups, keeping NT ACL support enabled while overriding defaults via masks is safer. It is also prudent to set unix charset = UTF-8 to ensure compatibility across different operating systems. For a deeper dive into connecting these shares to other systems, see our guide on Accessing Samba File Share between Ubuntu EC2 instance and Windows Server EC2 instance. This context helps in understanding cross-platform permission expectations.

Defining the Custom Share Section

Once the global settings are established, you define the specific share that requires custom access control. Create a new block starting with [my_custom_share], replacing the name with your desired identifier. Inside this block, specify the path to the directory you wish to share. The core of the customization involves the following parameters:
  • create mask: Defines the permissions for newly created files. A value of 0664 is common, allowing the owner and group to read and write.
  • directory mask: Defines the permissions for newly created directories. A value of 0775 ensures directories are executable by the owner and group.
  • force create mode: Overrides the client's requested mode. This ensures that even if a client tries to create a file with restricted permissions, your server enforces the specified mask.
  • force directory mode: Similar to force create mode but applies to directories.
  • inherit permissions: Setting this to yes can sometimes help inherit group ownership, though explicit masks are often more reliable for custom setups.
It is important to note that force create mode and force directory mode take precedence over standard masks. If you set force create mode = 0660, all new files will have those exact permissions, ignoring what the client attempted to send.

Handling Execute Permissions

A common point of confusion arises with executable files. By default, Samba may strip the execute bit from files unless they have a specific extension or are explicitly marked. To ensure that scripts or binaries uploaded to the share retain their executable status, you should use the preserve case and short preserve case options to maintain filename integrity. However, the key directive here is default case and case sensitive. More importantly, to "enable file mode and execute always," you can set force create mode to include the execute bit for the owner, such as 0770. Alternatively, if you only want to ensure executability for specific types, you might rely on the vfs objects module, specifically the fuse or xattr modules, but simple mask forcing is usually sufficient for local user scenarios. If you encounter issues where permissions appear correct locally but fail over the network, check for conflicts with existing ACLs. Our article on Resolving Samba Permissions Inconsistency Across Multiple Systems provides troubleshooting steps for these exact discrepancies.

Restarting and Testing

After saving your smb.conf file, you must restart the Samba services for changes to take effect. On systemd-based systems, run:
sudo systemctl restart smbd
sudo systemctl restart nmbd
Before testing, validate your configuration syntax using testparm. This command reads smb.conf and reports any errors or warnings. If testparm returns successfully, proceed to test the share from a client machine. Create a new file and directory within the share and verify their permissions using ls -l on the server side. They should match the masks defined in your configuration.

Frequently Asked Questions

Why do my file permissions change after uploading?

This usually happens because the client application specifies its own permission mode during creation. Using force create mode overrides the client's request, ensuring your server-side mask is always applied. Check your smb.conf to ensure these force options are active.

Can I mix local users with Active Directory users?

Yes, Samba supports both, but they require different authentication backends. Local users rely on smbpasswd or system passwords, while AD users use Kerberos. Ensure your security setting in [global] matches your intended authentication method to avoid access denied errors.

What is the difference between create mask and force create mode?

create mask sets the baseline permissions, but the client can still restrict them further. force create mode acts as a hard override, ensuring that the resulting file never has fewer permissions than specified, regardless of what the client requests.

How do I troubleshoot permission denied errors immediately after setup?

First, verify that the Linux directory itself has the correct ownership and permissions for the Samba service user (usually nobody or sambashare). Second, run testparm to catch syntax errors. Finally, check the Samba logs in /var/log/samba/ for detailed error messages regarding authentication or path access.

Is it safe to disable ACL support entirely?

Disabling ACLs (nt acl support = no) simplifies permission management but removes granular control over individual file attributes. It is generally safe for simple local user setups but not recommended if you need to manage complex security policies or integrate with Windows-specific security descriptors.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More