12

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.

2
  • 1
    change administrator's primary group to some other existing group
    – Skaperen
    Sep 23 '15 at 8:42
  • I tried to change administrator's primary group,but it can not work. $usermod -g test administrator $usermod: user 'administrator' does not exist in /etc/passwd $usermod: failed to unlock /etc/shadow 'administrator' even not exist in /etc/passwd. Sep 24 '15 at 2:01
11

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
8
  • userdel: cannot remove entry 'administrator' from /etc/passwd Sep 24 '15 at 1:54
  • @roadkiller180 Whats the output of getent passwd administrator ?
    – heemayl
    Sep 24 '15 at 1:58
  • administrator:*:10002:10007:Administrator:/home/administrator:/bin/bash Sep 24 '15 at 2:07
  • chenmark:*:10000:10007:Mark Chen:/home/chenmark:/bin/bash wulucy:*:10001:10007:Lucy wu:/home/wulucy:/bin/bash cathysong:*:10007:10007:cathy song:/home/cathysong:/bin/bash zhumike:*:50000:10007:mike zhu:/home/zhumike:/bin/bash pro1:*:50001:10007:pro1:/home/pro1:/bin/bash test:*:50002:10007:test:/home/test:/bin/bash It's very strange, Every new user's GID is 10007,Do you why? Sep 24 '15 at 2:11
  • @roadkiller180 yeah, there could be configurations leading to this..why are the UIDs>10000 ? Also whats the output of grep 'administrator' /etc/passwd ?
    – heemayl
    Sep 24 '15 at 2:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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