Create a user account using the USERADD command in Linux

Home > Search > Linux commands

The useradd command can be used to create a users account in Linux.

Create user

The useradd command followed by username can be used to create a user account.

~]# useradd JohnDoe


Change password

The -p command can be used to create a password for the user.

~]# useradd -p MyPassword JohnDoe


Create home directory

The -d command can be used to create the users home directory. In this example, the home directory is /home/JohnDoe.

~]# useradd -d /home/JohnDoe JohnDoe


Create default shell

The -s command can be used create the users default shell (/bin/bash in this example).

~]# useradd -s /bin/bash JohnDoe


Join a group

The -G option can be used to add a new user to a group. In this example, JohnDoe is added to group1.

~]# useradd -G group1 JohnDoe


Add comment

The -c option can be used to add a comment. The comment is typically the users first and last name.

~]# useradd -c "John Doe" JohnDoe


Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter in the box below so that we can be sure you are a human.