How to change www-data default rights when uploading directories/files?

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 20.0.5): 23.02
Operating system and version (eg, Ubuntu 20.04): Ubuntu 20.04
Apache or nginx version (eg, Apache 2.4.25): Apache 2.4.41
PHP version (eg, 7.4): PHP 7.4.3

The issue you are facing:

My www-data default user creates file permissions as below, when uploading them via web client.

drwxr-sr-x   2 www-data sftp 4,0K lut 21 21:01  TestDir
-rw-r--r--   1 www-data sftp 2,9M lut  9 09:00  TestFile

Probably I have mess with permissions. Where should I head to change them?
I don’t want to run chmod / chgrp each time I upload any files

What I’d like to have after upload to my nextcloud server is below:

drwxrwx---   2 www-data www-data 4,0K lut 21 21:01  TestDir
-rwxrwx---   1 www-data www-data 2,9M lut  9 09:00  TestFile

Any link to manual for that?
I’m googling “how to change default file permissions for www-data nextcloud user” and I keep getting answers around chmod / chgrp / chown. So surely I ask wrong question :slight_smile:

hello @Shadow82 welcome to the forum :handshake:

likely you did because by default permissions fit your desire.

maybe the right search term would be “ubuntu www-data user default group” or “ubuntu www-data user default umask” together with your OS (second is less specific but some discussions explain the user rights mechanics very well). e.g. I find this one which looks similar to your problem

https://www.ryadel.com/en/linux-set-default-group-creating-new-files-ftp-ssh-ubuntu/

A better way would be, trying to avoid issues like that completely, by not messing around directly with the files in your Nextcloud data folder. :wink:

There are WebDAV clients for almost every operating system out there, and many systems even support it natively, which means it can be used via the standard file manager, at least to some extent. And even if you have to automate things, e.g. on a Linux system you could use curl or wget. There are also tools like Rclone which can be used to synchronize and push or pull files via WebDAV, and probably many more…