useradd Command in Linux (original) (raw)

Last Updated : 12 May, 2026

Creating user accounts is a fundamental responsibility of a Linux system administrator, enabling secure access control and proper permission management. Linux provides powerful tools to create and manage users efficiently, especially in multi-user and server environments.

Let us consider a command to add a user named test_user to the system. This command creates a new user account without additional customization.

**Command:

sudo useradd test_user

**Output:

Working with the useradd Command

**Syntax:

useradd [options] [user_name]

1. Create a User with a Custom Home Directory

This creates a new user and assigns a specific directory as the user’s home directory.

**Command:

sudo useradd -d /home/test_user test_user

**Output:

2. Create a User with a Specific User ID (UID)

This creates a user with a custom user ID instead of an automatically assigned one.

**Command:

sudo useradd -u 1234 test_user

**Output:

3. Create a User with a Specific Group ID (GID)

This assigns the user to an existing group using its group ID.

**Command:

sudo useradd -g 1000 test_user

**Output:

4. Create a User Without a Home Directory

This creates a user account without creating a home directory.

**Command:

sudo useradd -M test_user

**Output:

5. Create a User with an Account Expiry Date

This creates a user account that automatically expires on a specific date.

**Command:

sudo useradd -e 2020-05-30 test_user

**Output:

This adds descriptive information (such as full name or role) to the user account.

**Command:

sudo useradd -c "This is a test user" test_user

**Output:

7. Create a User with a Specific Login Shell

This sets a custom default shell for the user.

**Command:

sudo useradd -s /bin/sh test_user

**Output:

8. Display Help for the useradd Command

This displays all available options and usage information for useradd.

**Command:

sudo useradd --help

**Output:

Files Modified by useradd

When you run useradd, it's the command edits a set of system files to register the new user.

adduser vs useradd