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 was so sure of myself, I thought I knew about permissions. Until someone asked me this.

Having these users:

User   Group
----   -----
juan   juan
pedro  pedro
maria  maria
jose   jose
miguel miguel
eric   eric
lola   lola
paola  paola       

This directory: /opt/privado with Owner = juan:juan

Permissions:

juan 111
pedro  110
maria and jose 101
miguel and eric 100
lola   000

There are no common permissions for creating a group myGroup and assigning, for example, 110 because I have different permissions for a different group of users. How can this be done on Unix? Really the issue is for Linux, but maybe it is the same solution.

share|improve this question
add comment

2 Answers 2

up vote 7 down vote accepted

You want to use POSIX ACLs for this, if you can't create sensible groups. See the setfacl command.

share|improve this answer
    
I agree with @geekosaur. Also check the man pages for acl(5) and getfacl(1). –  jsbillings May 4 '12 at 22:08
    
Long live to man pages. Thanks man. –  Jhonnytunes May 5 '12 at 0:21
add comment

Unix allows one set of mode bits per file. On traditional implementations of Unix, you can control access by the owner, owner's group, and others — and that's it.

If you have a recent Unix (including Linux), you can use ACLs to solve this problem:

setfacl -m u:juan:7 -m u:pedro:6 -m u:maria:5 \
    -m u:jose:5 -m u:miguel:4 -m u:eric:4 -m u:lola:0 /opt/privado

You can then view the ACL with:

getfacl /opt/privado

POSIX ACLs are very powerful, yet pretty obscure in most circles. Check out the manpages for more information.

share|improve this answer
1  
@geekosaur answered this while I was typing my answer (and got my vote too as a result). –  Alexios May 4 '12 at 22:16
add comment

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.