useradd(8)
Create a new user account on the system.
Synopsis
useradd [OPTION]... LOGINDescription
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
| Flag | What it does |
|---|---|
-m | Create the user's home directory if it does not exist; copies files from /etc/skel |
-s SHELL | Set the login shell (e.g., /bin/bash); defaults to /bin/sh if not specified |
-d HOME | Set the home directory path; overrides the default /home/LOGIN |
-u UID | Assign a specific user ID; must be unique and non-negative |
-g GROUP | Assign primary group by name or GID; group must already exist |
-G GROUPS | Add user to supplementary groups (comma-separated list, no spaces) |
-c COMMENT | Set the GECOS field (full name or description) in /etc/passwd |
-e EXPIRE | Set account expiration date in YYYY-MM-DD format |
-p PASSWORD | Set encrypted password (use passwd command instead for security) |
-M | Do not create a home directory |
-N | Do 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 johnCreate user 'alice' with sudo and docker group membership
sudo useradd -m -G sudo,docker -s /bin/bash aliceCreate system-style user 'appuser' with specific UID and nologin shell
sudo useradd -u 1500 -d /home/appuser -s /usr/sbin/nologin appuserCreate temporary user with expiration date and comment
sudo useradd -m -e 2025-12-31 -c 'Temporary User' tempuserCreate service account without home directory and no login capability
sudo useradd -M -s /bin/false svc_accountCreate user with specific primary group and multiple supplementary groups
sudo useradd -m -g developers -G projecta,projectb devuser