Incompatible group permissions in Linux - Is it a bug?

Posted by Sachin on Ask Ubuntu See other posts from Ask Ubuntu or by Sachin
Published on 2012-06-16T18:33:53Z Indexed on 2012/06/17 21:24 UTC
Read the original article Hit count: 292

Filed under:
|
|

I am on Ubuntu 11.04. I am creating another user and placing an existing user in the group of other user, hoping to write in the home directory of other user.

# uname -a
Linux vini 2.6.38-11-generic #50-Ubuntu SMP Mon Sep 12 21:18:14 UTC
2011 i686 athlon i386 GNU/Linux
# whoami
sachin
# su root
# useradd -m -U foo               // create user foo
# usermod -a -G foo sachin      // add user `sachin' to group `foo'
# chmod 770 /home/foo/
# exit
# whoami
sachin
# cd /home/foo/
bash: cd: /home/foo/: Permission denied
# groups sachin
sachin : sachin foo

This is totally weird. Though user sachin is in group foo, and group bits for /home/foo/ is set to rwx, sachin can't chdir to /home/foo/. I am not able to understand this.

But, if at the exit step, I switch to sachin user from root, this is what happens:

# uname -a
Linux vini 2.6.38-11-generic #50-Ubuntu SMP Mon Sep 12 21:18:14 UTC
2011 i686 athlon i386 GNU/Linux
# whoami
sachin
# su root
# useradd -m -U foo               // create user foo
# usermod -a -G foo sachin      // add user `sachin' to group `foo'
# chmod 770 /home/foo/
# su sachin
# whoami
sachin
# cd /home/foo/
# ls
examples.desktop

Now, whatever is happening here is totally incomprehensible. Does su sachin inherits some permissions from the root user at this step?

Any explanations would be much appreciated.

© Ask Ubuntu or respective owner

Related posts about permissions

Related posts about users