$linuxjunkies
>

useradd(8)

Create a new user account on the system.

UbuntuDebianFedoraArch

Synopsis

useradd [OPTION]... LOGIN

Description

useradd is a low-level utility for adding users to a Linux system. It creates a new user account with a login name, optional home directory, shell, and group membership. All user account information is stored in system files like /etc/passwd and /etc/shadow.

On most modern distributions, use adduser (a higher-level wrapper) instead for interactive user creation. useradd is useful for scripting and advanced configurations where you need precise control over account parameters.

Common options

FlagWhat it does
-mCreate the user's home directory if it does not exist; copies files from /etc/skel
-s SHELLSet the login shell (e.g., /bin/bash); defaults to /bin/sh if not specified
-d HOMESet the home directory path; overrides the default /home/LOGIN
-u UIDAssign a specific user ID; must be unique and non-negative
-g GROUPAssign primary group by name or GID; group must already exist
-G GROUPSAdd user to supplementary groups (comma-separated list, no spaces)
-c COMMENTSet the GECOS field (full name or description) in /etc/passwd
-e EXPIRESet account expiration date in YYYY-MM-DD format
-p PASSWORDSet encrypted password (use passwd command instead for security)
-MDo not create a home directory
-NDo not create a user private group; use default group instead

Examples

Create user 'john' with home directory and bash shell

sudo useradd -m -s /bin/bash john

Create user 'alice' with sudo and docker group membership

sudo useradd -m -G sudo,docker -s /bin/bash alice

Create system-style user 'appuser' with specific UID and nologin shell

sudo useradd -u 1500 -d /home/appuser -s /usr/sbin/nologin appuser

Create temporary user with expiration date and comment

sudo useradd -m -e 2025-12-31 -c 'Temporary User' tempuser

Create service account without home directory and no login capability

sudo useradd -M -s /bin/false svc_account

Create user with specific primary group and multiple supplementary groups

sudo useradd -m -g developers -G projecta,projectb devuser

Related commands