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.
4 Answers
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
adduser
command will let you include all the default home directories automatically. So you can not with adduser directly.
you can use useradd
instead.
sudo useradd <username>
will create the user with the given user name.
While coming to UID , the Range 499 reserved for system users i.e in Linux each service creates its own user and below 499 UID will allocated for those users.
hope that helps.
useradd -M username
--- creates user without home directory
we can check it as tail -5 /etc/passwd
which doesnot show the users home directory as it shows nologin
useradd -u userspecificid username
user specific id will be displayed after 999