adduser command in Linux with Examples

Preface
Managing users is one of the most essential tasks in Linux system administration. It ensures the system runs smoothly with appropriate access for different users and services. The linux adduser command is a user-friendly tool that streamlines the task of constructing & managing user accounts. It serves as an alternative to the more basic useradd utility, offering additional features like interactive prompts and automated configurations.
With adduser linux, you can quickly create regular user accounts, system users for specific services, or even groups to organize access permissions. The tool also supports customizing user accounts with options for shells, home directories, and group memberships.
This guide renders an exhaustive explanation of the linux adduser command with practical examples. Whether you’re looking to add a user with a home directory, configure a custom shell, or explore how adduser with group functionality works, this tutorial will help you master this essential tool.
Install adduser

The linux adduser command is pre-installed on most modern Linux distributions, including Debian, Ubuntu, and their derivatives. However, on some systems, you might encounter the “debian adduser command not found” error. This typically happens if the tool is missing or was not included during the system installation.
To resolve this, install the adduser package employing your system’s package manager. For Debian-based systems such as Ubuntu, use:
sudo apt update
sudo apt install adduser
On Red Hat-based distributions such as Fedora, CentOS, etc., utilize:
sudo yum install adduser
or
sudo dnf install adduser
For systems using the Arch Linux package manager, try:
sudo pacman -S adduser
If you encounter the “useradd command not found” error, ensure that the shadow utilities are installed, as the adduser tool often relies on them. Use man adduser for detailed information about its installation and usage.
Checking the version of the adduser command can also help verify successful installation:
adduser --version
By ensuring the linux command adduser is installed and functional, you can efficiently manage users and groups on your system.
adduser Syntax

The syntax for the linux adduser command is simple yet versatile, making it ideal for both beginners and advanced administrators. The basic structure is:
adduser [OPTIONS] [USER_NAME]
For example, to add a new user named john:
adduser john
This command creates a regular user with a home directory (/home/john) and interactive prompts for setting a password and other details.
Linux adduser Options
You can customize the process with options:
–ingroup GROUP: Add the user to a specific group. For example:
adduser --ingroup developers alice
This adds the user alice and places them in the developers group, demonstrating adduser with group functionality.
–-shell SHELL: Specify the login shell. For instance:
adduser --shell /bin/zsh devuser
This sets Zsh as the default shell for devuser.
–home HOME_DIR: Define a custom home directory. Example:
adduser --home /custom/path projectuser
This creates projectuser with a home directory at /custom/path.
–disabled-password: Create a user without a password. Useful for system accounts:
adduser --disabled-password systemuser
–gecos “INFO”: Add additional user information like full name or phone number in a single command:
adduser --gecos "John Doe,,,+1234567890" john
–disabled-login: Prevent the user from logging in:
adduser --disabled-login guest
–no-create-home: Skip creating a home directory. This is ideal for service accounts:
adduser --no-create-home daemonuser
The linux adduser command supports a wide range of options, making it suitable for various use cases. Use man adduser to explore more options and examples, or compare its functionality with useradd to understand their differences.
adduser Examples

The linux adduser command is versatile and supports creating various types of users and groups. Here are detailed examples for different use cases.
Add a Regular User
Adding a regular user is a common task for Linux administrators. To create a new user with default settings, use:
adduser alice
This command creates the user alice with the following default configurations:
- A home directory at /home/alice.
- A unique user ID (UID).
- A primary group named alice.
- Interactive prompts to set a password and additional information like full name and contact details.
You can customize the process further:
To specify a login shell:
adduser --shell /bin/bash alice
To use a custom home directory:
adduser --home /custom/path alice
If you face errors like “useradd command not found” or “debian adduser command not found,” ensure the required packages are installed. This ensures smooth execution of the add user command linux.
Add a System User
System users are non-login accounts used for running services or applications securely. These users typically don’t have a home directory or login shell. To construct a system user:
adduser --system webapp
This command:
- Creates a user named webapp.
- Omits a home directory and login shell by default.
- Sets a low user ID (UID) reserved for system accounts.
You can add customization to this process:
To assign a specific shell, use:
adduser --system --shell /bin/false webapp
To link a home directory for a system user:
adduser --system --home /var/webapp webapp
System users are crucial for enhancing system security, as they isolate services under dedicated accounts.
Add Group
The linux addgroup command simplifies group creation, allowing administrators to organize users efficiently. To add a new group:
addgroup developers
This creates a group named developers. Groups help manage file permissions and system access more effectively.
Add a User to a Group
You can assign a user to an existing group with adduser ingroup functionality:
adduser alice developers
This command adds alice to the developers group, ensuring she inherits the group’s permissions.
For multiple groups, use:
usermod -aG group1,group2 alice
(While usermod is used for adding multiple groups, adduser linux command remains ideal for single-group assignments.)
Create a User and Assign a Group Simultaneously
When creating a new user, you can directly assign a group:
adduser --ingroup developers bob
This creates a user bob and places him in the developers group.
Verify Group Membership
After adding a user to a group, confirm membership:
groups alice
Add User Password Options
Password management is an essential part of the linux adduser command. With various options, you can create users with or without passwords depending on security requirements.
Disable Password Creation
To create a user without a password, use:
This is useful for:
adduser --disabled-password guest
- Temporary accounts that don’t require authentication.
- System accounts where password login isn’t needed.
- Automating processes where access is managed via SSH keys or tokens.
You can later assign a password using:
passwd guest
Predefine a Password
You can set a predefined password in the event of user creation:
echo "password" | adduser --gecos "" --disabled-login alice
This approach is suitable for automation scripts. However, ensure the script’s security to avoid exposing passwords.
Create a Locked Account
To create a user with a locked password:
adduser --disabled-login restricteduser
This prevents the user from logging in directly. Use this option for accounts meant for internal system tasks or restricted access.
Require Password Change on First Login
Force a user to reset their password after the first login:
passwd --expire alice
This is useful for improving account security when creating accounts for new users.
Generate Random Passwords
For added security, generate a random password with tools like openssl:
openssl rand -base64 12 | passwd --stdin alice
Add a User With a Custom Shell
The default shell for most users is Bash. However, the linux adduser command allows specifying a different shell based on user needs.
Specify a Shell During User Creation
To set a custom login shell:
adduser --shell /bin/zsh devuser
This assigns Zsh as the shell for devuser. Replace /bin/zsh with any shell path, such as /bin/ksh or /usr/bin/fish.
Use No Login Shell
For users who shouldn’t log in interactively, use:
adduser --shell /usr/sbin/nologin sysuser
This is often used for system accounts to enhance security.
Change an Existing User’s Shell
If a user already exists, modify their shell with:
chsh -s /bin/zsh alice
Common Use Cases for Custom Shells
- Developers: Assign Zsh or Fish for advanced scripting and features.
- Restricted Accounts: Use /usr/sbin/nologin or /bin/false to disable login.
- Testing: Set specific shells for testing environments.
To view all available shells on the system, check the /etc/shells file:
cat /etc/shells
Add a User Home Options
Home directories store a user’s personal files and settings. By default, add user linux creates a home directory in /home/username. However, you can customize this.
Mention a Custom Home Directory
Use the –home option to define a specific directory:
adduser --home /opt/custom_home projectuser
This creates the user projectuser and assigns /opt/custom_home as their home directory. This is useful for organizing directories based on projects or roles.
Build a User Without a Home Directory
For accounts that don’t require a home directory, use:
adduser --no-create-home tempuser
This is ideal for temporary accounts or system users.
Copy Configuration Files to the Home Directory
By default, linux adduser copies files from /etc/skel to the new home directory. These include basic configurations like .bashrc or .profile. To customize the default setup:
- Add files to /etc/skel.
- Create a new user, and these files will be copied automatically.
Modify Permissions of Home Directory
To change ownership or permissions after creating a user:
chmod 750 /opt/custom_home
chown projectuser:projectgroup /opt/custom_home
Verify Home Directory Configuration
To ensure the home directory is correctly set:
grep projectuser /etc/passwd
This shows the user details, including the home directory path.
Also Read: useradd vs. adduser: What Are the Differences?
Conclusion
The linux adduser command is an indispensable tool for effective system as well as user maintenance. Its flexibility allows administrators to create and customize user accounts, whether for regular users, system tasks, or grouped access. By using options like adduser –ingroup, setting up home directories, or specifying login shells, you can streamline your Linux system’s user management.
If you encounter errors like “useradd command not found” or “debian adduser command not found,” it typically indicates the package is missing. Install it employing your distribution’s package manager, such as sudo apt install adduser on Debian-based systems.
Understanding the difference between useradd or adduser also enhances your administrative skills. While useradd provides basic functionality, adduser linux command is designed for ease of use and automated configurations. Mastering this tool not only saves time but also reduces errors in managing user accounts and permissions. By regularly using the adduser linux command, you ensure better control and security for your Linux systems.