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.
drwxrwx--- 3 myuser myuser 4096 Feb 6 16:24 datadir
$ grep "^test" /etc/group
test:x:503:myuser
$ groups myuser
myuser : myuser test
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:You should check the permissions of
subdir
and/var
also. This is just an illustrative example.No, you're reading this backwards.
myuser
belongs to thetest
group, not the other way round.Changed group membership only takes effect after logging in again. You can confirm by running
groups
. Logging out and logging in again solves it.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.