www-data as chown but still remain write access as other user(s)

Hey all,

Currently I’m running a Wordpress multisite configuration. Here I’ve recursively set www-data as the owner of /var/www to allow Wordpress write access in it’s whole installation. All folders within /var/www have their permissions set to 755. Now I’d like to still connect to my server using SFTP to add/edit/delete files using another (sudo) user, which isn’t possible.

What would be presumed best practice to solve this problem? Thanks in advance! Lorenzo

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.


you can create a new group

groupadd www-pub

add your (sudo) user and www-data to this group

usermod -a -G www-pub www-data
usermod -a -G www-pub username

change directory owner

chown -R www-data:www-pub /var/www

change permissions for the directory

chmod 2775 /var/www

the “prefix” 2 is a Set group ID bit, which causes the group to be copied to all new files and folders created in that folder. This does not work recursively, so you need to set it for existing folders manually

find /var/www -type d -exec chmod 2775 {} + # set directories to 2775
find /var/www -type f -exec chmod 0664 {} + # set files to 0664

It works and allows you to create a file and all files created there from FTP is with username:www-pub but even after placing that file not allows you delete that file as in this case again it shows permission denied.

Any Suggestions


you can add your (sudo) user to the same group as www-data and then add read/write/execute permissions to the directory (775) for this group. Something like this: