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

43,477

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
Share:
43,477

Related videos on Youtube

roadkiller180
Author by

roadkiller180

Updated on September 18, 2022

Comments

  • roadkiller180
    roadkiller180 over 1 year

    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.

    • Skaperen
      Skaperen over 8 years
      change administrator's primary group to some other existing group
    • roadkiller180
      roadkiller180 over 8 years
      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.
  • roadkiller180
    roadkiller180 over 8 years
    userdel: cannot remove entry 'administrator' from /etc/passwd
  • heemayl
    heemayl over 8 years
    @roadkiller180 Whats the output of getent passwd administrator ?
  • roadkiller180
    roadkiller180 over 8 years
    administrator:*:10002:10007:Administrator:/home/administrato‌​r:/bin/bash
  • roadkiller180
    roadkiller180 over 8 years
    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?
  • heemayl
    heemayl over 8 years
    @roadkiller180 yeah, there could be configurations leading to this..why are the UIDs>10000 ? Also whats the output of grep 'administrator' /etc/passwd ?
  • roadkiller180
    roadkiller180 over 8 years
    grep 'administrator' /etc/passwd output: postgres:*:111:120:PostgreSQLadministrator,,,:/var/lib/postg‌​resql:/bin/bash
  • roadkiller180
    roadkiller180 over 8 years
    I set UID range in smb.conf from 10000-20000 at the first time,and now change to 50000-60000,so you can see some UID like 50002,50001 as i mentioned in the previous comment.
  • heemayl
    heemayl over 8 years
    @roadkiller180 This behavior that you can't remove users that are not in /etc/passwd is a known bug.. bugs.launchpad.net/ubuntu/+source/accountsservice/+bug/98807‌​2 ..as you are using samba you are affected by this..also if you have any conf related issues with samba like the GID issue you have mentioned, you should ask that as a new question..