I recently set up Nextcloud using the latest NextcloudPi docker image incl. bullseye debian. Everything works smoothly, but I ran into one issue:
I have multiple folders in my Nextcloud of which some were created via the web interface and some via the Windows 11 client. One huge folder containing several GB of Photo was generated in /var/www/nextcloud/…/ncp/files/ by copying them from an external HDD. When I check the permissions for folders inside the Photos folder, I see that all folders that I transferred from the external HDD have “root” as owner and group, while files that were added via the web interface/Windows client (and all other files) have “www-data” as user (example shown here):
drwxr-xr-x 8 root root 4096 Nov 25 09:29 Faxen
-rw-r–r-- 1 www-data www-data 21160 Oct 14 10:03 Filler01.png
Why is this relevant? Because I have no writing permissions in all the Photo folders to e.g. upload photos from my Smartphone using the Nextcloud Android app or the Autosync app. These apps upload successfully in all folders that are “www-data” owner/group. So I assume that the “root” owner/group causes the problem here.
As a side note: The scan and indexing of the manually transferred files worked smoothly and I can see all photos in my Nextcloud.
Can I just change the owner/group? Or does this break something else? Is there any option via the Nextcloud admin interface to change the ownership of folders and files? Any suggestion how to proceed here is highly appreciated.
Yes, you were supposed to have changed the permissions when you copied them. If they are owned by root, Nextcloud will get access denied when trying to manage them.
All files must be owned by www-data:www-data with permission 640 on files and 750 on folders.
Thanks for the quick reply. I am not unix proficient. Is it safe to just run sudo chown -R www-data:www-data /var/www/nextcloud ? Or does that break anything else?