What Is the useradd Command in Linux?¶
Introduction¶
The useradd command creates local Linux user accounts. It is useful for beginners, Linux administrators, DevOps engineers, and RHCSA students because it solves practical terminal tasks.
What the Command Does¶
Use useradd to work with the specific Linux object it manages. Before changing anything, identify the target and run a read-only check when possible.
Basic Syntax¶
useradd OPTIONS USERNAME
The syntax includes the command, any options, and the target object.
Common Options¶
-m: create a home directory.-s: set login shell.-G: set supplementary groups.
Practical Examples¶
sudo useradd student
sudo useradd -m -s /bin/bash student
sudo useradd -m -G wheel student
sudo passwd student
Verification command:
id student
Example output:
uid=1001(student) gid=1001(student) groups=1001(student)
When to Use This Command¶
Use useradd when creating local accounts for users, service accounts, or lab tasks. Set the home directory, shell, and groups at creation time when the requirements are known.
Common Mistakes¶
- Creating an interactive user without
-mwhen a home directory is required. - Forgetting to set a password or configure SSH access.
- Using
-Gbut forgetting the required supplementary groups.
Quick Reference¶
sudo useradd student
sudo useradd -m -s /bin/bash student
id student
Related Guides¶
Summary¶
The useradd command is safest when you understand the target, choose the right option, and verify the result with a separate command.