I want to add new user in red hat linux.Username must be in numeric i.e username 123456.I was trying to add but its given invalid user name so it is possible to add new username only in numeric.


2 Answers 2


my suggestion for accomplishing this which in non conventional, would be to create a valid user such as a23456 using the adduser command, for example:

adduser a23456 --uid 123456 --gid users --groups users --create-home --comment firstname\ lastname

Then manually edit /etc/passwd and /etc/shadow and change the first character on the corresponding line from an a to a 1 for the username to meet your needs.

What may break or not work in RHEL after that I don't know.

Whether you change the home directory name to match is up to you.

double check the /home/a23456 or /home/123456 home directory ownership and make sure it matches what is in /etc/passwd for uid and gid.


If you go low level, you can add non-standard names.

Open a terminal (Ctrl-Alt-T is your friend, at least on Debian or Ubuntu), and check the manpage (stop with q):

man useradd

You will find an option --badname, so something like useradd --badname 🚀 should work.

Good luck. I'm not accepting any liability.

  • 1
    This answer should be tagged ubuntu (and not just for opening the terminal). REL systems along with some other distributions don't support --badnames.
    – doneal24
    Sep 21 at 17:16
  • @doneal24 : on the other hand : REL systems do have --badname me@somevm:/home/me >uname -a Linux somevm 5.14.0-165.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Sep 17 14:08:33 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux me@somevm:/home/me >cat /etc/centos-release CentOS Stream release 9 me@somevm:/home/me >man useradd | grep -A 1 bad --badname Allow names that do not conform to standards. me@somevm:/home/me >
    – JdeHaan
    Sep 23 at 12:20

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.