[CentOS] directory permissions

Paul Heinlein heinlein at madboa.com
Tue Jan 12 21:58:48 UTC 2010

On Tue, 12 Jan 2010, Carlos Santana wrote:

> Hi,
> I have changed directory ownership permissions recursively such that 
> it is owned by username:groupname , where groupname is not the 
> default group, i.e., username. However, when a user creates a new 
> file the default permissions are again username:username.
> How can I give ownership permissions on a particular directory so 
> that any files created in that directory will always have specifc 
> username:groupname permissions?

chmod 2775 /your/directory

This will assign group ownership of any files created in 
/your/directory to the group that owns that directory.

It won't, however, change user ownership. Allowing that sort of 
operation would be a great avenue for a denial-of-service attach on 
any filesystem with quotas.

> Also is there any option that would allow only owner to delete 
> files, even though group has rwx permissions?

chmod 3775 /your/directory

This combines the 2775 trick mentioned above with an o+s operation. 
Setting the "sticky bit" on the all-users permissions allows only 
owners to dispose of files. See the permissions on /tmp or /var/tmp 
for an example.

Paul Heinlein <> heinlein at madboa.com <> http://www.madboa.com/

More information about the CentOS mailing list