1

I have a linux web server with 2 hard-drives. There are 2 users, one can access /home/user1 and the other user can access /home2/user2

I would like to grant user1 permissions to access /home2/users/ (recursively) without revoking user2 access to his home directory.

What's the best way to do that?

migrated from stackoverflow.com Apr 6 '12 at 21:44

This question came from our site for professional and enthusiast programmers.

  • 2
    Put both into the same group or use ACLs. In any case, this is off-topic here, promoted to move to serverfault :) – Niklas B. Apr 6 '12 at 11:16
1

put both of them in the same group, and change the permission for the following:

RWX------ /home1/user1
RWXRWX--- /home2/user2

Thanks to @Niklas B: you'll also need to set /home2/user2 dir SGID to the group they both members.

if it's the main user2's group it'll be automatic, if not- use 'chgrp' command (don't forget -r for recursive! =))

  • Why change the permissions of /home1/user1? This is not necessary (at least not if you create a new group for the purpose) – Niklas B. Apr 6 '12 at 11:18
  • No really needed, this is just the usual permission for home folders – shem Apr 6 '12 at 11:19
  • 1
    Still, you'd need the SGID bit on /home/user2 to make the permissions propagate. – Niklas B. Apr 6 '12 at 11:21
  • Yes, absolutely- you're right. – shem Apr 6 '12 at 11:25
  • Please add that to the answer! You can edit on SO – Niklas B. Apr 6 '12 at 11:28
0

Create a group (users) for both users and grant the group r/w/x access to the second home dir ;)

  • Ahh, Niklas beat me by seconds :P – smassey Apr 6 '12 at 11:17
  • This is not a universal solution. At least you'd need SGID in addition to propagate this to new files and directories. – Niklas B. Apr 6 '12 at 11:17
0

If users are in same group, then you can set group permissions to folder users. Or if you not want other users access to /home2/users you can create new group and add user1 and user2 to it. After set permission on new group.

0

Have the user1 be in a group, say, group1 and allow group1 to access /home2/users.

Assuming you have setup user1 be in a group called "group1"

chgrp -R group1 /home2/users

chmod -R 770 /home2/users

If you want the files/dirs created under /home2/users to be accessible by user1 (regardless who created it) in the future then you will need to set the SGID: chmod g+s /home2/users Note that the above command can only be set by the /home2/users owner.

Can you elaborate more on your objective? Why does user1 needs to access user2's home directory? Will it be bad if user2 can access user1's home directory?

  • Man, this is the fourth duplicate of the same answer, and faulty in the exact same way! Please see my comments to the other answers for an idea of what I mean. – Niklas B. Apr 6 '12 at 11:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy