Skip to content

useradd command

Create user accounts.

On this page

Syntax

useradd [options] usernameadduser username (Debian/Ubuntu)

Provided by the passwd / shadow-utils package. Run man useradd for the full manual.

Common options

OptionWhat it does
-mCreate the home directory
-s SHELLLogin shell
-G GROUPSExtra groups
-u UIDUser ID
-rSystem account
-d DIRHome directory path
-e DATEAccount expiry date

Examples

  1. Create a user with a home and Bash

    sudo useradd -m -s /bin/bash alice
  2. Set the password

    sudo passwd alice
  3. Interactive (Ubuntu/Debian)

    sudo adduser alice
  4. Create a user with sudo rights (Ubuntu)

    sudo useradd -m -s /bin/bash -G sudo alice
  5. Create a user with sudo rights (RHEL)

    sudo useradd -m -G wheel alice
  6. System user for a service

    sudo useradd -r -s /usr/sbin/nologin appuser
  7. Delete a user and their home

    sudo userdel -r alice

useradd guides

← All Linux commands · Suggest a fix

Back to top