Difference Between Adduser and Useradd

An operating system is used to give instructions to hardware. Linux is an operating system. It is a clone of UNIX. The main advantage of  Linux is that programmers can build their own operating systems using the Kernel. Some widely used Linux distributions are Ubuntu, Fedora and Debian. The most frequently done tasks of the computer are browsing, creating, moving and deleting files. There are two methods to handle files efficiently. That is by using the Command Line Interface (CLI) or by using the Graphical User Interface (GUI). Using CLI is better in Linux because it is flexible and fast. Commands are given using the CLI and Linux contains a terminal to give commands. There is a large number of commands. The commands, adduser and useradd are for the user management. The key difference between adduser and useradd is that adduser is used to add users with setting up account’s home folder and other settings while useradd is a low-level utility command to add users. This article discusses the difference between these two commands.

CONTENTS

1. Overview and Key Difference
2. What is Adduser
3. What is Useradd
4. Similarities Between Adduser and Useradd
5. Side by Side Comparison – Adduser vs Useradd in Tabular Form
6. Summary

 What is Adduser?

Data can be changed or stolen. Therefore, it is vital to keep data secured. Security is the main concern in Linux. It is a multi-user operating system.  So there are authorisation levels in Linux. Every file in Linux or Unix has a user. There are three types of users in Linux. They are a user, group and other. ‘User’ is the owner of the file. By default, the user who creates the file becomes the user. ‘Group’ can contain multiple users. All users in the group have the same file permissions. It is possible to add many users to the group and assign group permissions. ‘Other’ doesn’t create the file, but they have access to the file.

In this way, the files are kept separately from each user. The users can read, write and execute. Read permission list the content. Write permission allows modifying the content. In Linux or Unix, it cannot run a program without the execute permission.

The adduser command is used to add users according to the command line options and configuration information. The command syntax is  $ command  – options arguments. There are some options with the adduser . The -h or –help is to print help screen. The –system is used to setup system users. The  –group is used to add a new group.

Figure 01: The adduser Command

Below shows the way of creating a new user using the command adduser. The name of the user is user_1. A normal user cannot add another user. It should run the commands as a super-user to add a user. Therefore, it should use “sudo”.

Figure 02: Adding a user called user_1 with adduser command

Figure 03: user_1 is created.

By viewing the content in the /etc/passwd , can view the user_1 details.

What is Useradd?

The command useradd is also used to add users. It comes with some flags.  Some of them are as follows.

-D        Defaults

-m        Creates a home directory

-s         Defines the shell for the user

-e         Date on which the user account will be disabled

-b         Base directory for the home directory of the user

-u         UID

-g         Initial group number

-G        Additional groups by name

-c         Comment

Figure 04: Default

An example of adding a user is as follows,

Figure 05: Creating user_2 with useradd command

Adding a new user cannot be done as a normal user. Therefore, it should use “sudo” for super user. The flag -m is used to create the user folder in home directory. “-s” is used to define the shell. “-g” is for the group and “-c” is for comments. After going to the home directory, user_2 will be created.

 What are the Similarities Between Adduser and Useradd?

  • Both are Linux commands.
  • Both can be used to create users.

What is the Difference Between Adduser and Useradd?

Adduser vs Useradd

Adduser is the command to add users to the system according to the command line options and configuration information in /etc/adduser.conf. Useradd is a low-level utility for adding users.
 Features
The command adduser creates the user and sets up the account’s home folders and other settings. The command useradd just creates the user.
Directory Creation
The command adduser creates a user directory in the home (/home/user ) automatically. The command useradd does not create a user directory in the home, if not specified with -m.
 Syntax Complexity
The command syntax for adduser is not complicated like in useradd. The useradd command has some complexity.

Summary – Adduser vs Useradd

Linux is popular among large organisations as well as among regular computer users. It is also used for server environments because of the reliability and stability. The user can give commands using Command Line Interface to perform various tasks. Two major commands for user management are adduser and useradd. The difference between adduser and useradd is that adduser is used to add users with setting up account’s home folder and other settings while useradd is a low-level utility command to add users.

Download the PDF Adduser vs Useradd

You can download PDF version of this article and use it for offline purposes as per citation note. Please download PDF version here Difference Between Adduser and Useradd

Reference:

1.ProgrammingKnowledge. Linux Command Line Tutorial For Beginners 22 – useradd command (Creating Users), ProgrammingKnowledge, 28 Dec. 2016. Available here
2.guru99com. Terminal V/s GUI – Linux Tutorial 4, Guru99, 26 Dec. 2012. Available here
3.hammadshams. Linux, creating a user in Linux, 1e4, Hammadshams, 23 June 2012. Available here 
4.Linux adduser command summary with examples, FactorPad, 10 Nov. 2016. Available here