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 want to remove user pserver from the group apache.

#deluser pserver apache
/usr/sbin/deluser: You may not remove the user from their primary group.

Now I want to add a new primary group, so I ran the following;

#usermod -G pserver pserver

Which returned the following:

pserver` is now in group `pserver

#groups pserver
pserver : apache pserver

Now I want to remove the user again from group apache, but I get same error again. How can I delete pserver from the primary group apache?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

The usermod option -G adds supplementary groups. You want option -g to change the primary group. I.e.:

# usermod -g pserver pserver

This will also change group ownership of files in the home directory, but not elsewhere.

share|improve this answer

Late, but a bit clear (at least for me);

sudo usermod -g <NewPrimaryGroupName> <TheTargetUserName>

And then check id

id <TheTargetUserName>

More details here: http://manpages.ubuntu.com/manpages/precise/man8/usermod.8.html

Credits: http://www.htpcbeginner.com/safely-change-primary-group-group-in-linux/

Thank for reply.

share|improve this answer

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.