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
?
Best Answer
The
usermod
option-G
adds supplementary groups. You want option-g
to change the primary group. I.e. your command should have been:Note, this will also change group ownership of files in the home directory, but not elsewhere.
More generally, the syntax for changing user 'user' to have primary group 'group' is: