useradd

Create New User Accounts

What Does It Do?

The useradd command creates new user accounts on a Linux system, setting up their home directory, shell, and user ID automatically.

Think of useradd like creating new employee badges and workspaces in a company. Each user gets their own login credentials, personal files area (home directory), and access permissions. IT administrators use it to onboard new employees, create service accounts for applications, set up test environments, manage system users, and configure multi-user servers.

Advertisement

[ Insert Google AdSense Banner Code Here ]

When Should I Use It?

New Employee Onboarding

Create accounts for new team members joining your organization.

Service Accounts

Create dedicated users for applications, databases, and services.

Testing Environments

Set up isolated test accounts for development and QA purposes.

Multi-User Servers

Configure shared systems where multiple people need separate logins.

Common Commands

cat /etc/passwd

List all users on the system (use this to see existing users).

sudo useradd john

Create a basic user account named "john".

sudo useradd -m sarah

Create user "sarah" with a home directory (/home/sarah).

sudo useradd -m -s /bin/bash alice

Create user "alice" with home directory and bash shell.

sudo useradd -m -G sudo,developers mike

Create user "mike" with home directory and add to groups.

sudo useradd -r -s /bin/false nginx

Create system user "nginx" for running services (no login).

IMPORTANT SECURITY WARNING

Always use sudo when creating users! The useradd command requires root privileges. Without sudo, the command will fail.

Don't forget to set a password! After creating a user with useradd, you must run sudo passwd username to set their password, otherwise they cannot log in.

Use -m flag for regular users: Always use useradd -m to create a home directory. Without it, users won't have a personal directory for their files.

Try It Yourself

Practice useradd commands in the interactive terminal below: