Data directory permission getting reset (Ubuntu)

I have a nextcloud installation (version 23.0.0) that runs on my Ubuntu server (OS: Ubuntu 20.04.4 LTS x86_64)

I am primarily using this for storing home documents and access it locally though I have a domain with SSL. I have moved the nextcloud data dictionary to external location (a mount on another drive) and have shared the directory through Samba. The user case is to have access to data dictionary and upload bulk documents.

The issue I am facing is that even when I have changed the permissions of data dictionary, the permissions get reset and I am not able to access the folder through mapped network drive.

Here is the screenshot for reference (nextcloud data directory is “data”:
As you can see the permissions is getting reversed to “drwxrwx—”

Can you let me know how to change the directory permissions permanently so that I can access that through Samba and mapped folder.

Thank you!

Perhaps you can give Samba the additional group www-data.

Thanks for the reply @devnull , can you please elaborate on your suggestion.

Linux (or UNIX) uses

user right
group right
other right

Maybe if Samba gets group access to www-data it works for Samba because not only user www-data but also group www-data has access to the data.

Thanks @devnull - adding the @www-data allows me to access the folder (previously I was not able to open the directory) but after that all files in the data directory is hidden and I am not able to create any files in it.

hidden? Post more details.
not able to create files? user www-data or Samba?

hidden - When I access that directory through shared drive via Mac, I am not able to see any files but I can see the files through Ubuntu terminal.
not able to create files - I am accessing the directory through shared Samba folder (I added www-data as group like you suggested(

Stop stop stop, Nextcloud needs to have exclusive access to the data folder. If you want other processes to deal with files as well, use a different folder and use this in Nextcloud as local external storage (“external” to the Nextcloud folder).

Other option, manage all files by smb, and use the smb external storage plugin. You can use smb-shares also as primary external storage. It’s a bit more complicated and not well documented (you will find a few posts here in the forum).


Thanks @tflidd - I have added the SMB as external folder and kept the code nextcloud data intact.