Back to the command reference

useradd

UsersFundamentals In real Linux

Create a new user

Name: useradd = user add

This command needs a real Linux system; you can practise it in real Linux mode.

Full man page

Description

useradd is the low-level tool to create user accounts. It may not create a home directory or set a password by default, so you typically add -m (home) and -s (shell), then set a password with passwd.

On Debian/Ubuntu the interactive adduser is friendlier.

Syntax

useradd [OPTION]... USER

Common options

-m / --create-homeCreate the home directory
-d / --home-dir DIRThe home directory (/home/NAME by default)
-s / --shell SHELLLogin shell
-g / --gid GROUPThe primary group
-G / --groups GROUPSSupplementary groups
-u / --uid UIDUser ID
-c / --comment COMMENTA comment (usually the full name)
-r / --systemA system user (for a service, no home directory)
-e / --expiredate DATEThe account expires on DATE, e.g. 2026-12-31

Examples

  • $ sudo useradd -m -s /bin/bash alice

    Create a user with a home directory

    Explain
  • $ sudo useradd -m -G sudo bob

    Create a user in the sudo group

    Explain

Related