How To Install adduser on Ubuntu 22.04

In this tutorial we learn how to install adduser on Ubuntu 22.04. adduser is add and remove users and groups

Introduction

In this tutorial we learn how to install adduser on Ubuntu 22.04.

What is adduser

adduser is:

This package includes the ‘adduser’ and ‘deluser’ commands for creating and removing users.

  • ‘adduser’ creates new users and groups and adds existing users to existing groups;
  • ‘deluser’ removes users and groups and removes users from a given group.

Adding users with ‘adduser’ is much easier than adding them manually. Adduser will choose appropriate UID and GID values, create a home directory, copy skeletal user configuration, and automate setting initial values for the user’s password, real name and so on.

Deluser can back up and remove users’ home directories and mail spool or all the files they own on the system.

A custom script can be executed after each of the commands.

There are three methods to install adduser on Ubuntu 22.04. We can use apt-get, apt and aptitude. In the following sections we will describe each method. You can choose one of them.

Install adduser Using apt-get

Update apt database with apt-get using the following command.

sudo apt-get update

After updating apt database, We can install adduser using apt-get by running the following command:

sudo apt-get -y install adduser

Install adduser Using apt

Update apt database with apt using the following command.

sudo apt update

After updating apt database, We can install adduser using apt by running the following command:

sudo apt -y install adduser

Install adduser Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Ubuntu. Update apt database with aptitude using the following command.

sudo aptitude update

After updating apt database, We can install adduser using aptitude by running the following command:

sudo aptitude -y install adduser

How To Uninstall adduser on Ubuntu 22.04

To uninstall only the adduser package we can use the following command:

sudo apt-get remove adduser

Uninstall adduser And Its Dependencies

To uninstall adduser and its dependencies that are no longer needed by Ubuntu 22.04, we can use the command below:

sudo apt-get -y autoremove adduser

Remove adduser Configurations and Data

To remove adduser configuration and data from Ubuntu 22.04 we can use the following command:

sudo apt-get -y purge adduser

Remove adduser configuration, data, and all of its dependencies

We can use the following command to remove adduser configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge adduser

References

Summary

In this tutorial we learn how to install adduser package on Ubuntu 22.04 using different package management tools: apt, apt-get and aptitude.