I have added the user "test" in myuser group usermod -a -G test myuser. But if I try to execute or try to cd to datadir as "test" user gives the Permission denied error. datadir is having the following privilege 770 and the user "test" belongs to myuser group and still it gives the Permission denied error.

4 Answers
4

You did not tell us about the parent directories permissions of datadir. Even if you have full permissions to a folder, you will not be able to access it unless you have the appropriate permissions to its parents also. So, you need to look at the full path permissions. For example, if you have a hierarchy like:

/var/subdir/datadir/

You should check the permissions of subdir and /var also. This is just an illustrative example.

see if "mysuser" shows up when the user runs groups. I'm suspect the problem is that the user doesn't have the group privileges in the shell which you are using. If you add a user to a group, existing logins won't get the group privilege. The user would have to login again to get the new privileges.

Alternatively, in an existing shell, the user can run newgrp myuser to create a subshell with this new group, however this has the effect of altering the default group for that user in that shell, so files created in that shell will by default be owned by mygroup instead of that users default group, which may or may not be desirable.