What is the Difference: useradd vs. adduser Linux?

Linus is a well-known operating system that provides a large list of commands. Each command has its features and functionalities. However, some of the commands perform the same functionalities but differ in their implementation or at the time of execution. For example, the  “useradd” and “adduser” add or create a new user into the system but execute differently.

Keeping this in view, the objective of this guide is to illustrate the difference between the “useradd” and “adduser” Linux commands. The content of this article is given below:

Let’s start with the “useradd” Linux command.

What is the “useradd” Command in Linux?

The “useradd” command is utilized to add a new user to the current working system. The “useradd” command changes are carried out in the following files.

  • /etc/passwd
  • /etc/group
  • /etc/gshadow
  • /etc/shadow
  • creates a “/home” directory for a new user

Syntax:

The generalized syntax of the user add command is as follows:

$ useradd [username]

Note: Only the root user can add a new user into the system. So before the creation process of a new user, log in as a root user or use the command to switch the current normal user to the root user. In addition, The user can also use the “sudo” command with the “useradd” to add a new user:

$ sudo su -

The practical implementation of the “useradd” command as a root user adding a “New_User” is displayed below:

# useradd New_User

The output shows that a “New_User” is successfully added into the current system.

To get detailed information about the “useradd” command, uses its manual page by following the command:

$ man useradd

What is the “adduser” Command in Linux?

The main purpose of the “adduser” command is the same as the “useradd” command to add a new user into the system. It provides an interactive prompt that creates a home directory, adds the “bash” shell as default, and asks the user to type a password.

Syntax

The syntax of the “adduser” command is typed here:

$ adduser [username]

Same as the “useradd” command, only the root user can add a new user using the “adduser” command. As an example, the “william” user is created in the system with the help of the “adduser” command:

$ adduser william

In this case, all the values are set by default as we don’t mention any information about “william” user. However, the user can add the user’s personal information as per requirements.

Get a brief overview of the “adduser” command with the help of its “man” page using the below-mentioned command:

$ man adduser

Now, move on to the difference between “useradd” and “adduser” Linux commands.

Difference Between “useradd” and “adduser” Linux Commands

The main objective of the “useradd” and the “adduser” is the same for adding a new user to the Linux system. However, they are different at the execution and implementation levels.

This section comprises these differences in the form of the table:

useradd Commandadduser Command
It is a low-level native binary compiled.It is the high-level “Perl” script that utilizes the “useradd” in the background.
It does not provide an interactive prompt.It is more interactive and user-friendly.
It is a soft link to the “adduser”.The “adduser” command is not present in most distributions.
It creates a “/home” directory with its “-m” option for the new user.It creates the “/home” directory by default.
Adds the new user in multiple groups at the same time.It needs to add a new user into multiple groups separately.
It does not ask for extra information for the user at the time of creation.Asks for a series of additional information such as “Full-name”, “Romm Number”, “Work Home” etc.

Which Command should use “useradd” or “adduser”?

Both the “useradd” and the “adduser” command is used to add the user but there is a difference in their execution.

The “adduser” command is more flexible as it is used when the user wants to add a “standard” user assigning the resources to the home directory and group. It is recommended to use the “adduser” user-friendly command to create a user by setting its password and some additional information.

The “useradd” command is useful when a user adds a temporary user into the system without allocating the home and group resources. It can perform the same job as the “adduser” command by using its supported options described on its “manual” page.

That’s all about the basics and the difference between the “useradd” and “adduser” commands.

Conclusion

The main difference between the “useradd” and “adduser” commands is their execution and implementation. The “useradd” command simply adds the user without allocating the “home” directory and the group. While the “adduser” command by default creates the “home” directory and sets the password and some additional information. This post has briefly explained the objective, usage, and difference between the “useradd” and “adduser” commands.