Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

4 Answers 4

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.

tadaa!

share|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.

share|improve this answer

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

share|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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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