5

I was trying to experiment with users, groups, and permissions. The results can be seen below:

vagrant@cats:/$ ls -l | grep home
drwxr-xr-x   5 root    admin    4096 Sep 28 05:49 home
vagrant@cats:/$ cat /etc/group | grep "^admin"
admin:x:1002:vagrant
vagrant@cats:/$ cd home
vagrant@cats:/home$ pwd
/home
vagrant@cats:/home$ cd ..
vagrant@cats:/$ sudo chmod 770 home
vagrant@cats:/$ ls -l | grep home
drwxrwx---   5 root    admin    4096 Sep 28 05:49 home
vagrant@cats:/$ cd home
-bash: cd: home: Permission denied
vagrant@cats:/$ ?

I don't understand why I can't get in. The user vagrant is in the group admin, the group admin owns the directory home and only the owner and or group members can read, write or execute files in home. But for some reason I'm locked out. What am I missing here?

1

1 Answer 1

13

If you have done changes to your user (adding or changing groups etcetera), you need to log out and then in again for them to take effect. Or you can change to your own user in a subshell (su vagrant) and try again.

2
  • There's also newgrp command.
    – TNW
    Sep 28, 2016 at 16:15
  • And exec newgrp will replace the current shell, saving you the extra exit or control-d when you go to log out. Oct 1, 2016 at 17:24

Not the answer you're looking for? Browse other questions tagged .