13

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.

heemayl
  • 90,425
  • 20
  • 200
  • 267
roadkiller180
  • 133
  • 1
  • 1
  • 4
  • 1
    change administrator's primary group to some other existing group – Skaperen Sep 23 '15 at 08: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. – roadkiller180 Sep 24 '15 at 02:01

1 Answers1

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
heemayl
  • 90,425
  • 20
  • 200
  • 267
  • userdel: cannot remove entry 'administrator' from /etc/passwd – roadkiller180 Sep 24 '15 at 01:54
  • @roadkiller180 Whats the output of `getent passwd administrator` ? – heemayl Sep 24 '15 at 01:58
  • administrator:*:10002:10007:Administrator:/home/administrator:/bin/bash – roadkiller180 Sep 24 '15 at 02: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? – roadkiller180 Sep 24 '15 at 02: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 02:14
  • grep 'administrator' /etc/passwd output: postgres:*:111:120:PostgreSQLadministrator,,,:/var/lib/postgresql:/bin/bash – roadkiller180 Sep 24 '15 at 02:41
  • 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. – roadkiller180 Sep 24 '15 at 02:45
  • @roadkiller180 This behavior that you can't remove users that are not in `/etc/passwd` is a known bug.. https://bugs.launchpad.net/ubuntu/+source/accountsservice/+bug/988072 ..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.. – heemayl Sep 24 '15 at 02:51