Useradd Issue – Why Home Directory Is Not Created When Creating a New User

useraddusers

I created a new user (testuser) using the useradd command on an Ubuntu server Virtual machine. I would like to create a home directory for the user and also give them root provileges.

However, when I login as the new user, it complains that there is no home directory. What am I doing wrong?

Best Answer

Finally I found how to do this myself:

   useradd -m -d /home/testuser/ -s /bin/bash -G sudo testuser

-m creates the home directory if it does not exist.
-d overrides the default home directory location. -s sets the login shell for the user.
-G expects a comma-separated list of groups that the user should belong to.

See man useradd for details.

Related Question