23

I am a research assistant in a neuroscience lab completely new to programming. I'm just trying to make a username in the ubuntu system I downloaded to run an MRI analysis program for someone else. And I don't even understand what this basic command means. I know regex means "regular expression" but can someone please tell me what an acceptable entry would be if I want my username to be "Icymoguls," or at least point me to a tutorial? I learned about /,~, cd, and ls in an intro video but don't know anything else. Thank you

1

3 Answers 3

26

The regex error you are seeing is basically saying that the username you tried to set does not meet the "rules" your system has set for what characters can be in usernames. By default, Ubuntu does not allow capital letters in usernames. The username you provided, "Icymoguls," has a capital letter at the beginning and therefore Ubuntu will not accept it.

Ubuntu only accepts usernames based on the following rules:

  • Must start with a lowercase letter
  • May only contain lowercase letters, underscore (_), and dash (-)
  • May optionally end with a dollar sign ($)

A regular expression is merely a string that shows what is and what is not allowed in another string. When creating a new user, Ubuntu checks potential usernames against its builtin regular expression for usernames (which is ^[a-z][-a-z0-9_]*\$ in case you were curious!).

1
  • 1
    Any idea why the Ubuntu devs set up the regex to reject uppercase letters?
    – Venryx
    Commented May 22, 2021 at 17:15
2

I think that instead of ^[a-z][-a-z0-9_]*\$, the regex should be ^[a-z][-a-z0-9_]*\$?$. The trailing $ is optional and the regex should match the entire string.

1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Dec 7, 2022 at 22:11
0

It seems that there is a reason behind this limitation.

If you try to run systemd service for scripts, it can be starting as root and not as a user. It's caused by systemd not recognize user with dot (domain.com user name for example) as valid user and runs service as root instead. Still this can be fixed already on systemd side, but still has a risk.

Also having dots in the user name creates some issues with scripts using chown, which still accepts dots as separator between user name and group name. If chown still accepts dots, there will be scripts using this notation, which will break if a user name contains a dot.

Still you can edit /etc/adduser.conf and amend the regex or use straight command useradd, but then you are responsible to create home -m flag and supply skelleton -k SKEL_DIR and do all the groups manually.

You must log in to answer this question.

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