SOLVED: Nextcloud can read Samba files but cannot save changes — Linux permissions explained for beginners

SOLVED: Nextcloud can read Samba files but cannot save changes — Linux permissions explained for beginners

Environment: Nextcloud 35 in Docker, Raspberry Pi OS, Samba, and an external EXT4 hard drive.

The problem

I wanted one household file collection accessible from Windows and Chromebook computers through Samba (SMB), and through Nextcloud’s web interface.

Nextcloud could open the files, but when I edited one, it could not save the changes.

The important lesson was that permission to read a file does not automatically include permission to modify it.

What caused the failure?

Our original test file was created from a Linux terminal using sudo. It had these permissions:

Owner=root
Group=household
Permissions=644

With permissions 644, only the owner (root) can write to the file. Nextcloud could read it, but its web-server process could not save changes.

The Nextcloud log confirmed a Permission denied error when attempting to write the file.

Our working solution

We use a shared Linux group named household for files accessed through Samba and Nextcloud.

Our arrangement includes:

  • Samba users belonging to the household group.

  • Nextcloud’s web-server user (www-data) having access to that group inside its Docker container.

  • Shared directories with group inheritance and write access.

  • Shared files with group read/write permissions.

Our working Samba share configuration includes:

[Family]
    path = /mnt/homelab/household/Family
    valid users = rowlette lora
    force group = household
    create mask = 0660
    directory mask = 02770
    read only = no

Important: Samba’s create mask limits permission bits; it does not guarantee that every new file will receive group-write permission. Always verify actual file permissions.

Understanding the permissions

Directories: 2770

  • 2 — New files and folders inherit the directory’s group.

  • 7 — Owner has full access.

  • 7 — Group has full access.

  • 0 — Others have no access.

Files: 660

  • 6 — Owner can read and write.

  • 6 — Group can read and write.

  • 0 — Others have no access.

To inspect permissions without changing anything:

stat -c 'Owner=%U | Group=%G | Permissions=%a' "/path/to/file.txt"

Replace the example path with your actual file.

For our original root-owned test file, we corrected only that file’s permissions:

sudo chmod 664 "/path/to/test-file.txt"

This allowed group writing. It did not change ownership.

Do not recursively change permissions throughout Nextcloud or your household files without understanding the consequences.

Docker consideration

Our Nextcloud container uses a customized image so its Apache web-server process belongs to the correct shared group.

The shared household directory is also mounted inside the container.

If you use Docker, check the group membership and filesystem access inside the container, not just on the Linux host.

How we verified the solution

We tested the entire process:

  1. Created a folder through Samba using a Chromebook.

  2. Verified the folder belonged to household and had permissions 2770.

  3. Created a text file through the Chromebook’s Samba connection.

  4. Verified the file belonged to household and had permissions 660.

  5. Opened the file in Nextcloud.

  6. Added a second line using Nextcloud Text.

  7. Read the actual file directly from the Linux hard drive.

The final file contained:

Samba permissions test
Nextcloud write test successful

Both lines were present on disk.

Result: Successful read and write access through Samba and Nextcloud, verified against the same physical file.

Advice for Linux beginners

If Nextcloud opens a file but cannot save it:

  1. Check the file’s owner and group.

  2. Check whether the group has write permission.

  3. Confirm that Nextcloud’s web-server process has the required group access.

  4. If using Docker, verify access inside the container.

  5. Test with a disposable file before changing important documents.

Avoid creating ordinary shared files using sudo unless you understand the ownership and permissions that will result.

This was a Linux filesystem permissions issue in our Samba/Nextcloud integration, not a confirmed Nextcloud software bug.

Our solution is specific to our environment, but the diagnostic approach may help others with similar symptoms.

Acknowledgment: This solution was developed collaboratively by a HomeLab user learning Linux and ChatGPT (OpenAI). ChatGPT assisted with technical diagnosis and instructions; the HomeLab user performed the configuration, testing, and independent verification of the results.

So you didn’t try to use the external storage so that Nextcloud accesses the files through samba? This way, you pass the whole user/group-permissions to samba (e.g. you could manage different groups, personal space etc.).

Thank you for the suggestion. I hadn’t considered using Nextcloud’s External Storage feature to access the files through Samba instead of directly through the filesystem.

Our HomeLab uses Samba as the primary interface to a shared household directory on an external 4 TB drive. Nextcloud runs separately in Docker.

I’m trying to keep the architecture simple, reliable, and maintainable for family members who aren’t familiar with Linux.

I’ll investigate the SMB external storage approach before making changes. It may be a cleaner solution to the permissions problem.

I appreciate your taking the time to explain this alternative.

It depends a bit, if you only want to access a shared folder, then your solution is sufficient. But perhaps you want to change or extend one time, or others try to do something different.

@yodatheone1 its clear you’re not using the snap, but the procedure is similar regardless of installation method, see