Permissions, users and access

Command useradd

Create a user

Linux · Bash examples · commands run on the selected server

When to use useradd

Use useradd for deliberate local account creation on a Linux server. Defaults vary by distribution, so specify important settings and inspect the result before allowing remote access or assigning privileges.

Syntax

useradd [PARAMETERS] NAME

Square brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.

Common options and arguments

-m
Create a home directory.
-s SHELL
Select login shell.
-G GROUPS
Specify additional groups separated by commas.

Usage examples

Create a separate user

sudo useradd -m -s /bin/bash demo-user

The account is created with a home directory and the specified login shell.

Check the created entry

id demo-user

The new account's numeric IDs and groups are checked.

Check default settings

useradd -D

Current account-creation defaults are displayed without creating another account.

Notes and limitations

  • Creating a user does not set a regular password: configure the login method separately.
  • Default settings vary by distribution and configuration shadow-utils.

Common questions and troubleshooting

Does creating an account enable SSH login automatically?

Not necessarily. Authentication material, account state, SSH server policy and filesystem permissions must also allow login.

Why is the home directory missing?

Some distributions do not create it by default. Request home creation explicitly when appropriate and verify the configured home path.

Further help

Options vary by version and distribution. Check the installed documentation with this command: man useradd.