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] NAMESquare 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
Usage examples
Create a separate user
sudo useradd -m -s /bin/bash demo-userThe account is created with a home directory and the specified login shell.
Check the created entry
id demo-userThe new account's numeric IDs and groups are checked.
Check default settings
useradd -DCurrent 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.