Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 8 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:


Thank for reply.

share|improve this answer

Your Answer


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.