Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

It is likely that you just need to logout and login again to let the new permission to become effective.

share|improve this answer

Have you tried doing this with adduser instead? The Ubuntu Help page recommends not using useradd. I think what your trying to do could be done like this:

adduser newuser (automatically makes home folder)

adduser newuser olduser (this adds newuser to the olduser group)

Hope that helps.

EDIT:

This should at least help you figure out if the problem is related to usermod or not. Try to add the user and change groups without using useradd or usermod.

share|improve this answer
    
Actually as I said in the question, the problem is not of adding a new user, that is working fine. The problem is of adding an existing user to the new user's group. I tried adding the old user to the new user created using adduser but the problem persists –  Sachin Jun 15 '12 at 6:51
1  
adduser user group adds user to group per adduser(1) –  Michael Wild Jun 15 '12 at 7:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.