1

I created folder /home/john/Desktop/test.
I want to give it access to user john itself and to user mike.

I created group:

sudo groupadd jm


And added users to same group:

sudo usermod -a -G jm john
sudo usermod -a -G jm mike

Then gave right:

sudo chgrp -R jm /home/john/Desktop/test
sudo chmod -R 770 /home/john/Desktop/test

When I login with mike and write cd /home/john/Desktop/test , it writes Permission denied.

What may be the problem?

Output of ls -la:

drwxrwx---+ 2 john jm 4096 Nov 7 15:35 test
it dev
  • 315
  • Does Mike have access to John's home directory and the Desktop directory? The jm group (or "others") needs at least x permissions on all intermediate directories between / and /home/john/Desktop/test. – Kusalananda Nov 07 '18 at 12:37
  • No, Mike does not have access to John's home and Desktop directory. How to give access to Mike to that folders? – it dev Nov 07 '18 at 12:42
  • chmod o+x /home/john /home/john/Desktop or (but you probably don't want this) chgrp jm /home/john /home/john/Desktop followed by chmod g+x /home/john /home/john/Desktop. – Kusalananda Nov 07 '18 at 12:49
  • thank you @Kusalananda. So it means it is better to create directory in the root (/) of linux and give access to other users. – it dev Nov 07 '18 at 12:52
  • Well, no matter where you create it, all users that should have access to it needs to also have at least x access to all the directories above it. – Kusalananda Nov 07 '18 at 12:54
  • @Kusalananda, very clear! Thank you very much! – it dev Nov 07 '18 at 12:55

1 Answers1

7

To summarise the discussions in the comments below the question itself:

For a user to have access to a directory, the user also has to have at least execute permissions on all directories above that directory, and on the directory itself. This may be achieved through either of the user, group or "other" permission bits.

For user mike to have access to the directory /home/john/Desktop/test, the user must therefore have x permissions on all of the directories

  • /,
  • /home,
  • /home/john,
  • /home/john/Desktop, and on
  • /home/john/Desktop/test.

If the user is not the owner of a directory in this list, they must be part of a group that has x permissions on it, or the directory must have x permissions set for "others".

Related:

Kusalananda
  • 333,661