I have a folder /home/samantha/folder that I want to share with the user tom (he can read, write the folder). How do I do that?

chown wouldn't do it, because I still want to be able to be the owner of the folder... I don't see how to do this with chmod either.

link|improve this question

What operating system are you using? – grawity Jan 19 '11 at 21:20
feedback

1 Answer

up vote 3 down vote accepted

If you are using Linux with a relatively modern filesystem (ext3/ext4, btrfs, ntfs), this can be done with POSIX ACLs:

  1. Enable ACLs for the filesystem.

    1. For current session:

      mount -o remount,acl /
      
    2. To make it stay after reboot, add the acl option to the appropriate line in /etc/fstab

  2. Give tom access to the folder:

    setfacl -m user:tom:rwx /home/samantha/folder
    

If the OS or the filesystem does not support ACLs, another way is to use groups.

  1. Create a group.

    • Some Linux distributions create a separate group for each user: tom would automatically be in a group also named tom.

    • If not, create a group. This should work on Linux...

      groupadd tom
      gpasswd -a tom tom
      

      ...and this - on BSD:

      groupadd tom
      usermod -G tom tom
      
  2. chgrp the directory to that group, and give permissions with chmod:

     chgrp tom /home/samantha/folder
     chmod g+rwx /home/samantha/folder
    
link|improve this answer
thanks a million times grawity! :) – Zenet Jan 20 '11 at 5:02
feedback

Your Answer

 
or
required, but never shown

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