Linux Command #38 – useradd (Linux OS)

Linux Command #38 useradd cover with neon-green title and an Ubuntu-style dark terminal showing sudo useradd -m alex and sudo passwd alex

useradd creates a new Linux user account.

Think of it like adding a new person to a computer’s list of recognized users. The new account can then have its own username, home directory, password, files, and permissions.

The simple command

sudo useradd -m alex

This example has three easy parts:

  • sudo runs the administrative command with elevated privileges.
  • useradd creates the account.
  • -m tells useradd to create the user’s home directory if it does not already exist.
  • alex is the new username.

After this command, the new home directory is normally /home/alex.

Video 1: useradd from the beginning

This focused Linux tutorial introduces the useradd command and creating users.

Give the new user a password

The previous lesson covered Linux Command #37 – passwd. The two commands fit together naturally.

sudo passwd alex

Linux asks you to enter the new password and then type it again. The password itself is not normally displayed while you type it.

A simple account-creation sequence is therefore:

sudo useradd -m alex
sudo passwd alex

Check that the account exists

You can use the earlier getent lesson to look up the account:

getent passwd alex

If the account exists, you should get a line of account information for alex.

Video 2: Creating users with useradd

This lesson demonstrates creating Linux users with useradd.

Why use -m?

A home directory gives the user a normal place for personal files and configuration files.

sudo useradd -m alex

The -m option explicitly requests home-directory creation. This is useful because account defaults can vary between Linux distributions and system configurations.

You can check the directory with:

ls -ld /home/alex

A simple workplace example

Imagine a new technician named Alex joins a team and needs an authorized Linux account on a training server. An administrator could create the account, create its home directory, set an initial password according to company policy, and then verify the account record.

sudo useradd -m alex
sudo passwd alex
getent passwd alex

Each command has one clear job: create → set password → verify.

Video 3: Practical useradd options

This recent beginner tutorial demonstrates useradd and common options such as creating a home directory.

useradd does not mean “give every permission”

Creating an account does not automatically mean the new user should become an administrator. Give users only the access they actually need. Group membership and administrative privileges should follow the system owner’s policy.

Common beginner mistakes

  • Forgetting sudo when administrative privileges are required.
  • Forgetting -m when you intend to create a normal home directory explicitly.
  • Creating the account but forgetting to handle its password or login policy.
  • Assuming every Linux distribution has identical account-creation defaults.
  • Giving a new account more permissions than it needs.

Quick practice

Only do this on a Linux system or lab that you are authorized to administer.

  1. Create a test user with a home directory: sudo useradd -m alex.
  2. Set the account password according to your lab’s rules: sudo passwd alex.
  3. Verify the account: getent passwd alex.
  4. Check the home directory: ls -ld /home/alex.
  5. Explain what the -m option does.

Key takeaway

useradd creates a Linux user account. A beginner-friendly pattern is sudo useradd -m username, followed by the system’s approved password/login setup and a quick verification with getent passwd username.

Leave a comment