Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a directory with ownersip like user:group. I want to make on it something like sgid, but for user - all of new created files have a directory ownership. For example:

drwxrwx--- 2 user   group   4096 Jun  3 16:10 test

And all created files in it have automaticly set following ownership on user:

-rwxrw---- 1 user group1 0 Jun  3 16:11 file1
-rwxrw---- 1 user group2 0 Jun  3 16:11 file2
-rwxrw---- 1 user group3 0 Jun  3 16:11 file3

It is possible to do this?

share|improve this question

2 Answers 2

You can not do this. Standard Unix permissions can only go so far, at one point one has to consider using ACLs.

You should consider what needs your system has. If you absolutely need this you should start reading up on ACLs.

Here is the page on Arch Wiki on the subject. Most of this will probably work for any Linux distribution, as well as Solaris since Linux mostly copied Solaris's ACLs.

share|improve this answer
    
Sorry, but the Q is about Solaris, ZFS does not support extended ALC, but it supports NFSv4 ACL. Anyway, I suppose there are no possibility to do what aku asked. –  dchirikov Jun 3 at 16:13
    
Oh, sorry, apparently I need to work in my reading! Second time today I do this kind of thing. –  arnefm Jun 3 at 16:26
    
Fortunately, Linux got its ACLs from Solaris, so apart from the part about enabling ACLs, most of the content of the Arch wiki page also applies to Solaris. –  Gilles Jun 3 at 23:21

I don't think that Solaris allows a non-root user to give away files to another user. So you cannot make newly created files owned by another user: the files will remain owned by the user who created them.

What you can do is arrange for a user to have extra permissions on the files, via an access control list. If you set an ACL entry for user alice, then the permissions in that entry will apply instead of the traditional Unix permissions. You can use the chmod command or setfacl to set ACLs, and ls -v](http://docs.oracle.com/cd/E26502_01/html/E29030/ls-1.html#scrolltoc) or [getfacl` to view the ACL on a file. In addition to the ACL that applies to itself, a directory has a default ACL, which is applied to files newly created in that directory. Thus you need to set the default ACL on the toplevel directory.

chmod A+default:user:alice:rwx test
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.