Permissions

useradd

Create a local user account.

useraccountadminloginhome

Additional Notes

useradd creates a local user account. It can set a home directory, login shell, UID, primary group, supplementary groups, and account metadata.

On Debian and Ubuntu systems, adduser is often friendlier for interactive account creation, while useradd is lower-level and script-friendly.

Syntax

useradd [options] username

Parameters

  • options: Flags that change how useradd behaves.
  • user: User account affected by the command.
  • group: Group account affected by the command.
  • file: File or directory whose ownership, mode, or access policy is being changed.

Common Options

  • -m, --create-home: Create the user's home directory.
  • -d DIR, --home-dir DIR: Set home directory path.
  • -s SHELL, --shell SHELL: Set login shell.
  • -g GROUP: Set primary group.
  • -G GROUPS: Set supplementary groups.
  • -u UID: Set numeric user ID.
  • -c COMMENT: Set comment/GECOS field.
  • -r, --system: Create a system account.
  • -M: Do not create a home directory.

Examples

sudo useradd -m deploy

Create user deploy with a home directory.

sudo useradd -m -s /bin/bash alice

Create alice with Bash as login shell.

sudo useradd -m -G sudo,docker alice

Create alice and add supplementary groups.

sudo passwd alice

Set the new user's password.

id alice

Check the new account identity and groups.

Practical Notes

  • Always set or configure authentication after creating a login account.
  • Use -m unless you intentionally do not want a home directory.
  • Supplementary group changes apply on new login sessions.
  • Service accounts often use -r and a non-login shell.
  • Review /etc/passwd, /etc/shadow, and /etc/group only if you understand their format.