useradd vs. adduser Linux with Examples

While managing users, Linux administrators need to manage different types of users based on the privileges he/she wants to set. User management includes access control and Group management of the user. It is often seen that when we create users in Linux, there are two types of commands available useradd and adduser. This post will have an overview of both commands and discuss some key differences between them.

useradd Command

The useradd is a command used for creating a user in any Linux-based operating system. It is a low-level or less secure command for creating a user because it only creates a user until we specify a flag. This command does not create a home directory until a -m flag is specified.

adduser Command

This adduser command is a relatively less complex and more secure command used for creating a user. It automatically sets the home directory and other user settings and saves all the configuration in the /etc/adduser.conf file.

Let’s create users using both useradd and adduser command and see the difference.

Examples

First, we will create a user using the useradd command.

Create a user using the useradd Command

To create a user using the useradd command, type the command given below:

In the above command, Ivan is the username, so provide your username at the place of Ivan.

You can witness in the screenshot attached; the user is created without asking for any password.

To create a password for this user, execute the command given below:

Type the new password you want to set for the user:


After successfully creating a user and setting its password, log in to the user profile using the command given below:


Type the recently created password for the newly created user:


You can see we are logged in to Ivan’s shell, and you can also witness that the user does not have the home directory.

Create a user using the adduser Command

To create a user using the adduser command, type the command given below:

In the above command, replace the username with your username.

After hitting enter, this adduser command will first ask for setting up the password for the user.

Once you have set the password for the user bob, it will ask for setting the user information like username, Work Phone, Home Phone, etc.

Provide the details or skip them by leaving the fields empty and pressing the “Enter” button.

At last, it will verify the information authentication, type ‘y’, and hit ‘Enter.’

The user is successfully created, and you can log in to its shell using the command mentioned below:


Enter the password:

You are logged in to the newly created user’s terminal.

Conclusion

Verily we have seen the obvious difference between the user add and adduser command. The adduser command is the latest command used to create a user. In contrast, the useradd command is very basic and complex since the adduser uses the useradd binaries behind it, so it is not yet available in all the Linux distros. At the same time, useradd can be used in any Linux-based operating system.