Ubunu Server Inherit directory permissions and ownership

0

Before I begin, I apologize if this may seem as if it is a duplicate question, but no responses that I have found have been able to solve my problem.

I have a server setup running my company, with several users on the system.

When working with the website, all files need the permissions of www-data, however, when i create a file as matt or taylor, the files are always created with the users default permissions, so matt:ceo or taylor:staff. I need new files in the www-data directory to always inherit the permissions of {user}:www-data as well as have a default permission setting of 660.

In my current setup, I need to use sudo to chmod, and chown to correct everything.

Any and all help is greatly appreciated.

Matt Clark

Posted 2012-12-23T17:51:47.530

Reputation: 1 819

Answers

1

If you set the setgid bit for the www-data directory, all the files created under it will have the group set to that of the directory. The command to do this is:

chmod g+s www-data

Don't forget to add the users to the group that owns the directory, e.g.

usermod -a -G www-data matt
usermod -a -G www-data taylor

I don't know how you can set the default permission to 660 except using umask but that will apply to all files no matter where are created.

Cristian Ciupitu

Posted 2012-12-23T17:51:47.530

Reputation: 4 515

Well then... that was simple... thanks a ton. – Matt Clark – 2012-12-23T18:02:17.107

0

Permissions can be inherited using default ACLs, if your filesystem supports them:

setfacl -d -m u::rwx,g::rwx,o::- www-data

user1686

Posted 2012-12-23T17:51:47.530

Reputation: 283 655