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

15,961

Solution 1

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

Solution 2

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.

Share:
15,961

Related videos on Youtube

Nick
Author by

Nick

Updated on September 18, 2022

Comments

  • Nick
    Nick over 1 year

    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.

  • Anwar
    Anwar almost 7 years
    where is the answer for specific UID ?