Ubuntu – How to create a new user without home directory and with specific UID

addusercommand linegnome-terminalusers

How can I add a new user "Kids" with UID = 500 and without home directory with adduser command in terminal? I'm trying this: sudo adduser --no-create-home --uid ID 500 Kids and after correctly entering password it says that value "ID" is invalid for option uid. Then I have tried the same thing only without "ID" and got: 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.

Best Answer

First - UIDs less than 1000 are usually system reserved, pick a higher UID.

Second - Why are you wanting it to not have a home directory. Keep in mind the --no-create-home doesn't mean the user doesn't have a home directory assigned, it just isn't created. An error will be logged every time that user logs in.

Third - Please remember to post errors your get, else we can only assume as to what the problem is. I'm assuming it has to do with the name format, in which case, you can bypass this using --force-badname, as the error message would say, or use all lower case characters.

*edit typo