I am trying to create a new user in Ubuntu 14.04 LTS from the bash command line. I use the following commands:
sudo useradd -c "Samwise the Brave" sam
sudo passwd sam
Enter new UNIX password: hello-1234
Retype new UNIX password: hello-1234
passwd: password updated successfully
After creating this new user, I encountered 3 issues:
-
I am not able to log into Ubuntu using user sam. Whenever I log in, I am sent back to the login screen.
-
When I look into the
/etc/passwd
file, I can see that there are no default shells defined for user sam:cat /etc/passwd | grep sam sam:x:1003:1003:Samwise the Brave:/home/sam:
-
Sam's home folder was not created, i.e.
/home/sam
doesn't exist.
Any clues about what could cause all these issues?
I should note here that when I create a user using the Unity Control Center, these problems do not occur. But I would like to be able to use the command line since I have dozens of users to create.
Best Answer
First notice that it's better to use adduser and not useradd.
Now back to your command:
You should run the command in the following manner:
man useradd
So you miss to use
-s
to add your login shell and the-m
to create your home.If you want to add multiple users in the same time, it's better to use the command
newusers
. It'll simplify your task.man newusers
Here some tutorial about
newusers
command: