Debian – Can’t add user because group already exists

debianuseradd

I initially added a user (adduser MYUSER) and then deleted it (deluser MYUSER). Now I'm trying to add it again (adduser MYUSER) and I get the following message:

adduser: The group 'MYUSER' already exists.

When I checked, the group does indeed exist. So, I assume I would need to delete the group (groupdel MYUSER), but this happens:

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

Best Answer

adduser creates a dedicated primary group for each user, with the same name as the user. (It can be configured differently, but evidently it is configured to do this on your system. This is the default configuration.) Running deluser deletes the user but not their primary group, even if the group was added by adduser and had no other members.

If you want the user to use the existing group as its primary group, pass the option --ingroup MYSER to adduser.

Related Question