LinuxCommandLibrary

adduser

Add a new user account

TLDR

Create a new user with a default home directory and prompt the user to set a password

$ adduser [username]
copy

Create a new user without a home directory
$ adduser --no-create-home [username]
copy

Create a new user with a home directory at the specified path
$ adduser --home [path/to/home] [username]
copy

Create a new user with the specified shell set as the login shell
$ adduser --shell [path/to/shell] [username]
copy

Create a new user belonging to the specified group
$ adduser --ingroup [group] [username]
copy

SYNOPSIS

adduser [options] login
adduser [options] system username
adduser [options] --group | -g --ingroup group [username]

PARAMETERS

--system
    Create a system account (no home, expires never)

--home | -d HOME_DIR
    Set home directory

--shell SHELL
    Set login shell

--ingroup GROUP | -g GID
    Set primary group

--groups CSV_GROUPS
    Add to supplementary groups

--disabled-password
    Account valid without password (locked)

--disabled-login
    Account expires immediately (disabled)

--gecos GECOS
    Set comment/full name field

--uid UID
    Specify user ID

--gid GID
    Specify group ID

--comment COMMENT
    Set GECOS comment

--create-home | -m
    Create home directory

--no-create-home | -M
    Do not create home directory

--skel SKEL_DIR
    Skeleton directory

--force-badname
    Allow invalid usernames

--quiet
    Suppress some messages

--debug
    Enable debug output

DESCRIPTION

adduser is a higher-level utility for creating new user accounts on Debian-based Linux systems, serving as a user-friendly wrapper around the low-level useradd command. Unlike useradd, which requires manual specification of all details, adduser is primarily interactive: it prompts for essential information like full name, room number, phone numbers (GECOS fields), and password, using sensible defaults from /etc/adduser.conf. It automatically creates the user's home directory (from /etc/skel), sets permissions, adds the user to specified groups, and updates mail spools if configured.

It supports both regular and system users, with options for non-interactive (batch) mode via config files or command-line flags. System users get no home directory or password by default, suitable for daemons. adduser also handles group creation with addgroup integration and locks accounts until passworded. It's Perl-based, ensuring portability and extensibility.

Key advantages include validation of inputs, UID/GID conflict checks, and integration with PAM for authentication. Always run as root. Common pitfalls include forgetting --system for service accounts or mismatching UIDs.

CAVEATS

Requires root privileges; modifies /etc/passwd, /etc/group, /etc/shadow. Interactive by default—use --quiet for scripts. UID conflicts auto-resolved unless --uid specified. Not identical to useradd on non-Debian systems.

INTERACTIVE USAGE

Run adduser username for prompts on password, GECOS; auto-creates home/group.

BATCH MODE

Preconfigure /etc/adduser.conf (DSHELL, HOME, GROUP); use adduser --quiet username.

EXAMPLE: SYSTEM USER

adduser --system --group --no-create-home mydaemon

HISTORY

Originated in Debian (1990s) as Perl script in adduser package by Ian Jackson. Evolved with shadow suite; now standard on Ubuntu, Mint. Maintains backward compatibility while adding PAM/modern crypto support.

SEE ALSO

useradd(8), addgroup(8), deluser(8), usermod(8), userdel(8), groupadd(8)

Copied to clipboard