28

I'm running Ubuntu 12.10 desktop 32 bit. Currently I have only a user, type administrator. I'd like to create another administrator user but I keep getting the following error:

Failed to create user

GDBus.Error:org.freedesktop.Accounts.Error.Failed: running '/usr/sbin/adduser' failed: /usr/sbin/adduser returned an error (1): adduser: Please enter a username matching the regular expression configured via the NAME_REGEX[_SYSTEM] configuration variable. Use the `--force-badname' option to relax this check or reconfigure NAME_REGEX.

Any suggestion is appreciated.

2

5 Answers 5

22

The username you're entering contains bad characters. Try entering a simple username containing only lower-case English letters - daniel is good, &&Daniel <*> Johnson## is not so good.

2
  • 2
    This is the correct answer. It would be helpful if the error message showed the actual regex instead of the variable name... Sep 10, 2018 at 12:02
  • This worked with me..( lower-case). Thank you. Feb 13, 2020 at 2:42
17

You normally get this message if you are trying to create a user with a name that contains characters that are considered to be un acceptable as per your NAME_REGEX file. You can try again changing the username with the GUI or you can relax the check by using the command line with the following command.

sudo adduser --force-badname <username>

and then if you want to add the user to the sudo group run the following command.

sudo adduser <username> sudo
2
  • 2
    -1, I wouldn't encourage doing that. The restriction is probably in place for a reason. Aug 27, 2014 at 15:28
  • 1
    @nyuszika7h I wonder how could this affect the system? Just looking for an example here since I create a user for my mail account.
    – sitilge
    Jun 15, 2015 at 11:42
14

In Debian systems, the regex defining acceptable user names is found in /etc/adduser.conf.

A typical regex (found on my system) is:

NAME_REGEX="^[a-z][-a-z0-9_]*\$"

I don't want to veer too far off topic with regex parsing, but the caret ^ symbol indicates the beginning character of the user name must be between lowercase a and lowercase z. The remaining characters may be lowercase a-z, 0-9, hyphen, or underscore. As mentioned in other answers, you can override this check if you like. By default, regexes are case-sensitive.

2

I faced the same problem -and I solved it- when I wrote

# adduser --home /Ali Ali

I got the error of

adduser --home /Ali Ali
adduser: Please enter a username matching the regular expression configured
via the NAME_REGEX configuration variable.  Use the `--force-badname'
option to relax this check or reconfigure NAME_REGEX.

I solved it just by removing the uppercase letters as shown below

# adduser --home /ali ali
Adding user `ali' ...
Adding new group `ali' (1001) ...
Adding new user `ali' (1001) with group `ali' ...
Creating home directory `/ali' ...
Copying files from `/etc/skel' ...
passwd:     
passwd: password updated successfully
0
0

You can force this by using the --force-badname option 'adduser --force-badname Ali', or by changing the regex in the aforementioned config-file, however...

The reason upper-case letters aren't normally allowed is that it leads to ambiguous and confusing usernames, both to humans and to programs. I.e. John, john, JOHn, and JOHN, would all be separate usernames, if allowed or forced (sixteen variations with four of the same letters, upper and lower-case). As to other symbols, it could lead to catastrophic and dire consequences in some cases-- for example having the pipe symbol '|' would probably be a really bad idea, because it means something in the command-line, and sometimes to other programs that might not deal well with it in a username. With caps, standard email in particular is usually not case-sensitive, and could lead to mixed up or undeliverable mailboxes if used this way-- normally reverting all to lower-case, because that's the historical standard, not to mention whatever is contained in the RFC's. Be careful if you tread outside those bounds. I'm not saying never do it-- but be advised and consider that it would be experimental and may not be freindly to all your purposes.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .