Ubuntu – groupdel: cannot remove the primary group of user ‘administrator’

groupsuser-managementusers

When I try to delete the group pro1 (groupdel pro1) it shows the error:

groupdel: cannot remove the primary group of user 'administrator'

And when I create new user from AD server, the user's default group is pro1.

How can I fix this problem? Thanks.

Best Answer

This is documented in the man page. From man groupdel:

You may not remove the primary group of any existing user. You must remove the user before you remove the group.

So you need to make the primary group of user administrator something other than pro1 and then you should be able to remove group pro1.

Example:

$ sudo groupdel foobar 
groupdel: cannot remove the primary group of user 'foobar'
$ sudo usermod -g foo foobar  ## Change the primary group of user "foobar" from "foobar" to "foo"
$ sudo groupdel foobar  ## Done