Overview
In Debian-based distributions like Ubuntu, Debian, or Kali Linux, the adduser command provides a user-friendly, interactive way to create user accounts. Unlike the low-level useradd command, adduser acts as a wizard that guides you through creating a home directory, copying default configuration files, and setting an initial password. This significantly reduces the administrative workload and is also a convenient tool for adding existing users to specific groups.
Specifications (Arguments and Options)
Syntax
BASH
# Create a new user
adduser [options] [username]
# Add an existing user to an existing group
adduser [username] [groupname]
Main Options
| Option | Description |
| –conf [file] | Uses a specific configuration file instead of the default adduser.conf. |
| –disabled-login | Disables login for the account by not setting a password. |
| –disabled-password | Creates the user without a password, often used for SSH key authentication. |
| –gecos [info] | Directly sets GECOS fields like full name or room number. |
| –gid [ID] | Specifies a primary group ID for the new user. |
| –group | Creates a group with the same name as the user (usually default). |
| –home [DIR] | Specifies a custom path for the home directory. |
| –shell [SHELL] | Sets the default login shell (e.g., /bin/bash). |
| –ingroup [group] | Sets an existing group as the primary group for the new user. |
| –no-create-home | Does not create a home directory. |
| –system | Creates a system user with a lower UID and no password. |
| –uid [ID] | Manually assigns a specific numeric User ID (UID). |
| –quiet | Suppresses progress messages and warnings. |
Basic Usage
This section demonstrates how to create a new user named “yui” using the interactive mode. During this process, the system will prompt you for a password and personal details like a full name.
BASH
# Creating a user interactively
sudo adduser yui
# Verifying the created user information
id yui
# Checking GECOS/Finger information
finger yui
# Checking password expiration details
sudo chage -l yui
Example Output
Adding user `yui' ...
Adding new group `yui' (1001) ...
Adding new user `yui' (1001) with group `yui' ...
Creating home directory `/home/yui' ...
Copying files from `/etc/skel' ...
New password: (Enter password)
Retype new password: (Re-enter password)
passwd: password updated successfully
Changing the user information for yui
Enter the new value, or press ENTER for the default
Full Name []: Yui Sato
Room Number []:
...
Is the information correct? [Y/n] y
Practical Commands
Adding an Existing User to a Group
You can easily add an existing user, such as an “infra_manager,” to a group with administrative privileges like “sudo” or “wheel.” This approach is often more intuitive than using the usermod command in Debian-based systems.
BASH
# Add user infra_manager to the sudo group
sudo adduser infra_manager sudo
Example Output
Adding user `infra_manager' to group `sudo' ...
Adding user infra_manager to group sudo
Done.
Creating a User with Shell and Comment Specified
To skip interactive prompts for specific items, you can define the shell or comments using options. This method is highly effective for batch processing or standardized setup tasks.
BASH
# Set shell to zsh and comment to "Application Deployer"
sudo adduser --shell /usr/bin/zsh --gecos "Application Deployer" app_user
# Verify the settings in the passwd file
grep app_user /etc/passwd
Example Output
app_user:x:1002:1002:Application Deployer,,,:/home/app_user:/usr/bin/zsh
Customization
The default behavior of adduser, including home directory locations, default shells, and UID ranges, is controlled by the /etc/adduser.conf file. If you want to change the default shell to zsh for all new users across the system, editing this configuration file is a cleaner solution than using command-line options every time.
BASH
# Edit the default configuration
sudo nano /etc/adduser.conf
# Change to DSHELL=/bin/zsh
Important Notes
In Red Hat-based distributions like RHEL or CentOS, adduser is often just a symbolic link to the useradd command. Consequently, it will not launch the interactive wizard described here, as that feature is specific to Debian and Ubuntu environments. Additionally, when adding a user to a group, ensure the syntax follows the “adduser [user] [group]” order, which differs from the argument logic used by useradd or usermod.
Advanced Usage
Creating a System User (–system)
When setting up automated services like a web server or a Discord bot, you should create a “system user” that is not intended for interactive login. These accounts typically receive a low UID (often below 1000) and do not have home directories created by default.
BASH
# Create a system user and group without a home directory
sudo adduser --system --group --no-create-home discord-bot
Summary
The adduser command is a highly accessible account management tool for anyone working within Debian-based Linux environments. By remembering that adduser handles both creating users and managing group memberships, administrators can perform daily tasks smoothly without memorizing complex low-level options. While useradd remains useful for automated scripts, adduser is the recommended choice for manual administrative work due to its guided nature.
