I am confused with groups in Linux. Considering that user1 is in both groups user1 and user2 (and vice versa):
user1> id user1
uid=1000(user1) gid=1000(user1) groups=1000(user1),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),50(staff),113(lpadmin),130(sambashare),131(vboxusers),1001(user2)
user1> id user2
uid=1001(user2) gid=1001(user2) groups=1001(user2),0(root),1000(user1)
I do not understand why user1 cannot edit a -rwxrw-r-- file owned by the user2 and group user2:
user1>ls -l hey.xml
-rwxrw-r-- 1 user2 user2 8385 May 24 11:39 hey.xml
user1>echo "fails" >> hey.xml
bash: hey.xml: Permission denied
but it works when I change the group:
user1> sudo chgrp user1 hey.xml
user1> echo "works" >> hey.xml
Once this question is hopefully answered, what can I do to always allow user1 to read-write files in that user2 group? Thanks
user2
log in before or after it was assigned to be a member of theuser1
group? – DopeGhoti May 24 '17 at 16:08