I am having this strange problem. I am using
usermod to add an existing user to another group. I want to create a new user and add an old user to this new user's group. To do this, I am doing the following things
Create a new user, -m creates the home directory for the user and -U creates a group by the same name, as that of the user.
useradd -U -m newuser
Then I add the old user to the new user's group as
usermod -a -G newuser olduser
-a appends this group to the already existing groups and
-G is used to give the group name.
Now when I do
groups olduser I get the following out put
olduser newuser, but being the
olduser I am unable to create a any file in the
newuser home directory. I have set the proper directory permissions, the read, write and execute bit is set for group.
However if, instead of using
usermod I manually edit the
/etc/group file, and add
newuser,olduser in front of the newuser group then everything works correctly. Is there a bug in
usermod or I am doing something wrong.