3 users, 1 folder. Users: vsftpd (FTP server), bobmarley (normal user), www-data (Apache user)

How to unite them and make so that each user can modify any of these user's data, without doing CHMOD 777?

Ex.: bobmarley created a file 'settings.inc.php' www-data tries to access the file, and succeeds. vsftpd user accesses the file and can modify it, too.


Create a group (groupadd)... chgrp of the directory to that new group... and then add each user to that group. That's the easiest way. You may also want to chmod g+s on the directory to make sure that new files are created with the same group as the parent directory.


| improve this answer | |
groupadd webapp
usermod -a -G webapp vsftpd (but I think it should be nobody)
usermod -a -G webapp bobmarley
usermod -a -G webapp www-data
chgrp -R webapp /path/to/folder
chmod -R g+w /path/to/folder

If you have existing data in this folder, you can set SGID for all sub-folders with:

find /path/to/folder -type d -print0 | xargs -0 chmod g+s /path/to/folder

Remember to set the umask for vsftpd, Apache and bobmarley to 002. With this config, all files created by any user will has 664 permission, owned by webapp group, and other users can modify.

| improve this answer | |

Put them all in a common group. chgrp the files to that group. chmod the files/dirs to 664/775.

| improve this answer | |

Group them. This is why there are groups in POSIX. Create a group xyz and put vsftpd, bobmarley and www-data into it.

And then assign the group to the folder/files with chgrp.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.