Cannot add a user account with numerical username - useradd: group '11' does not exist
Don't do this, instead use a username which starts with a characters like u11
.
Here is what's happening:
You are trying to create a user named 11
, so a group will be created named 11
at the same time as your user's primary group.
This newly created group will get an id bigger that of > 1000
like: 1003
which in your /etc/group
file its line going to be: 11:x:1003
.
While adding this new user useradd
tries to add it to its primary group which is 11
, however when doing this, it thinks that the 11
is a group id so it complains that there is no such group with the id of 11.
- When it says "group 11 exists", it means you have a group named "11", and
- When it says "group '11' does not exist", it means that I can't find any group with the id of "11".
Why it worked for first 10 account
Because by default there are some groups with the ID of 0 to the 10 in a Ubuntu system. so it assign your users to these groups and does not complain about it. However with the 11, you've got a group named 11
but no group with the id of 11
.
Workaround
So as muru said it's just the start of your problems, do not do this. however if you insist to fix the issue you should find the group id and use that:
$ grep ^11 /etc/group
11:x:1003
$ sudo useradd 11 -g 1003
Do not forget to use usermod
to change the first 10 users group id too.
Related videos on Youtube
Johan Liebert
Updated on September 18, 2022Comments
-
Johan Liebert over 1 year
I'm an amateur Kubuntu user, and have much to learn.
I am trying to create a user account which are named after numbers. I have
sudo
privileges and I tried it on the root account as well.Apparently, to add such an account, you have to use the command:
sudo adduser --force-badname
and then the number.
I tried this, and it worked for 10 accounts. During the eleventh, it failed and gave me an error message:
$ sudo adduser --force-badname 11 Allowing use of questionable username. Adding user `11' ... Adding new group `11' (1010) ... Adding new user `11' (1010) with group `11' ... useradd: group '11' does not exist adduser: `/usr/sbin/useradd -d /home/11 -g 11 -s /bin/bash -u 1010 11' returned error code 6. Exiting.
Eventually, I changed my command to
useradd
to add the account, and it claimed:useradd: group 11 exists - if you want to add this user to that group, use -g.
So I typed:
$ useradd -g 11 useradd: group '11' does not exist
So I resorted to the original adduser command:
adduser --force-badname 11
Allowing use of questionable username.adduser: The group `11' already exists.
At this point, I was angry, but I used the
groupdel
command to delete group 11. I triedgroupdel 11
. After confirming the command worked, I went on theadduser
command, and on the root account I typedadduser --force-badname 11
.And received the same error message as when I started!
Allowing use of questionable username. Adding user `11' ... Adding new group `11' (1010) ... Adding new user `11' (1012) with group `11' ... useradd: group '11' does not exist adduser: `/usr/sbin/useradd -d /home/11 -g 11 -s /bin/bash -u 1012 11' returned error code 6. Exiting.
-
muru almost 7 yearsThis is a terrible, terrible idea.
adduser
and co. won't be the first set of problems you'll face. Any number of commands will be confused by numerical usernames. Don't do this. -
ADDB almost 7 yearsWell you COULD do useradd -g 11 -ou 11 11 and then passwd 11 for setting password (-g sets group and -ou system group and at the end is the name of the user)
-
Ziazis almost 7 yearsI don't quite understand why someone would create users and groups only based on numbers? What reason is there anyway... if you really want it create user01 or group01. Other then that you have the explanation why it's having issues from Ravexina's answer.
-
Johan Liebert almost 7 yearsIt's because I'm partaking in a little project which requires 100 user accounts, and it's much more practical/ocd-friendly to make then all numbers. Also because I want to know why it doesn't work, even if I were to change my account names, I wouldn't want to leave without knowing why it didn't work. I control the terminal, not vice versa. BTW, I did not submit the question.
-
muru almost 7 years@JohanLiebert the why is simple: If a command accepts both usernames and user IDs, a username which is entirely numerical can be taken for either. By the way, disabuse yourself of the notion that you "control the terminal". Unless you wrote every command you use, that is simply false - each time you run a command, you're negotiating between your needs and what the command can do, and your actions always dictated by what the available commands can do.
-
Johan Liebert almost 7 yearsWait a minute, I did send this answer. And I thought someone else had the same problem.
-
Johan Liebert almost 7 yearsWhat I meant by controlling the terminal was purely metaphorical. I meant if a command doesn't work, I want to know what will make it work.
-
-
Johan Liebert almost 7 yearsOMG! SO helpful! One question though, is there a better way to create such a group than a failed adduser commad, and then the sudo useradd xx -g 10yy?
-
Ravexina almost 7 yearsYou can accept the answer if you think it was helpful to you :-) about your question: you can use
groupadd
to add the groups first then useuseradd uname -g gid
to create your users. Again it's not a good thing to do ;) -
Johan Liebert almost 7 yearsWhoops, my bad. Upvoted your answer. I finished making my 100 accounts. Apparently, on my os, the group was always one number less + 1000. So when I used the grep command for account 11, I got group 1010. When I used it for 61, the group was 1060.
-
Ravexina almost 7 years@JohanLiebert You can accept the answer if you like by clicking on the gray tick under number 4 ;)
-
Johan Liebert almost 7 yearsI did, but it said if the answer does not have 15 acceptations, the puclic score will not change.
-
Johan Liebert almost 7 yearsOh wait that's what it is, clicked it, it turned green.
-
Ravexina almost 7 yearsYeah, it's done now :) I hope you find these informations useful ;)
-
Johan Liebert almost 7 yearsIndeed I did. ;)