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:

  1. I am not able to log into Ubuntu using user sam. Whenever I log in, I am sent back to the login screen.

  2. 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:
  3. 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.


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:

sudo useradd -m -c "Samwise the Brave" sam  -s /bin/bash 

man useradd

  -s, --shell SHELL
           The name of the user's login shell. The default is to leave this
           field blank, which causes the system to select the default login
           shell specified by the SHELL variable in /etc/default/useradd, or
           an empty string by default.

 -m, --create-home
           Create the user's home directory if it does not exist. The files
           and directories contained in the skeleton directory (which can be
           defined with the -k option) will be copied to the home directory.

           By default, if this option is not specified and CREATE_HOME is not
           enabled, no home directories are created.

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


   The newusers command reads a file of user name and clear-text password
   pairs and uses this information to update a group of existing users or
   to create new users. Each line is in the same format as the standard
   password file (see passwd(5)) with the exceptions explained below:


Here some tutorial about newusers command:

  • Why do I get "unknown option m"? I am on AWS Ubuntu instance running 14.04. – Donato Sep 26 '16 at 0:39

While you are missing flags and the other answers aren't necessarily wrong, considering running adduser if you want it more comprehensive in the future. It's a prettier version of useradd. Namely it'll make a home directory by default unlike useradd. Also note when it asks for a ton of stuff, it stores that inline on the /etc/passwd file and you don't have to fill any of it out.


Thanks everyone. With your answers I've been able to fix the problem using the following command lines.

sudo useradd -c "Samwise the Brave" -m -s /bin/bash sam
echo -e "hello-1234\nhello-1234" | passwd sam

The password is set with passwd so it is already encrypted (otherwise "hello-1234" would appear not encrypted in /etc/passwd).


Create user

Create user's home directory

Define login shell

useradd -m -d /home/username username -s /bin/bash

Delete User

Deleter User's Home Directory

userdel -r username

You are missing flags in the useradd command. '-m' to create user directory, '-s /bin/bash' to add the bash shell. The default is to not create a user directory and to assign the default shell. My system did the same thing when I tested it so it looks like ubuntu 14.04 uses blank as the default shell. You can't login because you have no shell.

Create default home directory for existing user in terminal (Question 335961 , 3rd Answer)

From Ubuntu Manpage for useradd

   -s, --shell SHELL
       The name of the user´s login shell. The default is to leave this
       field blank, which causes the system to select the default login

How do you change the default shell for ALL USERS to bash? Question 335961

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.