0

I want to allow access to 2 users on one directory. I am trying since days but unable to do so! Let me make it simple for you guys to understand by giving a simple example. But first, Let me tell you that the user named admin should be able to access both the directories.

Consider two Directories:

  1. /var/www/directory1
  2. /var/www/directory2

and two users:

  1. user1
  2. user2

I want user1 to access only the directory directory1, user2 to access the directory directory2 and admin to access both the directories!

I tried giving ownership to respective directories to the users and the group named admin-group to let admin access both the directories. That didn't work well. I also tried giving write access to the group but failed.

Is it possible to do what I want? If possible, How can I?

1 Answers1

2

You could try the following:

chown user1:admin-group /var/www/directory1
chown user2:admin-group /var/www/directory2
chmod 770 /var/www/directory1
chmod 770 /var/www/directory2
usermod -aG admin-group admin

Then you have to make sure that new files created in the directories use the same permissions:

sudo chmod g+s /var/www/directory1
sudo chmod g+s /var/www/directory2
pa4080
  • 30,621