How can I remove a group (which was previously deleted) from a user which still references it? If I run groups, I get an error about a non-existent group:

$ groups
myuser dialout cdrom sudo dip plugdev fuse lpadmin sambashare groups: cannot find name for group ID 1001

The usual way of using deluser doesn't work because the group name no longer exists and there seems to be no flag for using IDs:

$ deluser myuser 1001
The group `1001' does not exist.

Is there a more straight forward way to remove a group (by ID) from a user other than by recreating the group, deleting the group from the user, and then redeleting the group?

  • There's still the easy fix: recreate the group (--uid=1001), remove it from the user's groups, and delete it again. – John WH Smith Oct 17 '14 at 17:18
  • @JohnWHSmith No, that wouldn't change anything. The group is deleted, so the user is no longer in the group. The user's running processes are in the group, that's different. – Gilles 'SO- stop being evil' Oct 17 '14 at 23:35

groups show you the groups you are in. So the problem is that your process thinks you still are in the now deleted 1001 group, from the deluser myuser 1001 command.

You still would get that error message from groups as long as the process you started thinks you are in the group. When doing these kind of things in bash for my own account, I normally start a new shell to make sure that things are as I want them to be in that shell.

In your case starting a new shell should solve the issue, if not then the group would still exists in /etc/group and then deluser would not complain.

  • Any idea about how to handle it in CentoOS ? deluser doesn't seem to exist, and userdel doesn't work. Finally, gpasswd apparently doesn't handle group ids... – Anto Apr 17 '18 at 11:12
  • @anto It is completely unclear what mean by 'it' in your comment? Do you mean you cannot handle restarting the shell? In the OP's question the group is already deleted, whether done deluser, gppasswd or userdel is completely irrelevant. – Anthon Apr 17 '18 at 12:13
  • "It" = op's question = "remove a group (which was previously deleted) from a user which still references it". I had the exact same issue under Centos, but deluser doesn't exist there, so I couldn't follow your solution. But I've finally solved it by re-creating the group and then removing it. – Anto Apr 17 '18 at 14:32

you can remove the reference to the group manually i.e. modify /etc/group

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.