The question is how to allow one user (but not all!) to access files of another user.
I have a directory /home/alice/dir
owned by alice
:
$ cd /home/alice
$ ls -l
drwxr-x--- 2 alice alice 4096 Feb 10 21:24 dir
i.e., owner alice
and group alice
have read/execute access.
I want to allow user bob
access to this directory, but any other user eve
should not have access.
What I did so far was:
$ sudo adduser bob alice
and now
$ getent group alice
alice:x:1001:bob
so now bob
is in the group alice
.
However, still bob
cannot access the directory:
$ whoami
bob
$ cd /home/alice
$ pwd
/home/alice
$ ls -l
drwxr-x--- 2 alice alice 4096 Feb 10 21:24 dir
$ getent group alice
alice:x:1001:bob
$ cd dir
bash: cd: test: Permission denied
What's wrong?
Users were created with
sudo adduser alice
sudo adduser bob
sudo adduser eve
dir
with at least execute rights for the groupalice
.bob
can navigate to the directory wheredir
is, and thels -l
output in my question is as seen bybob
from that directory. But thencd dir
fails forbob
, butsu sudo
andcd dir
works.bob
is a member ofalice
group. Please see the output ofgetent
in my question. I've added him to the group withsudo adduser bob alice
.