useradd Command Examples in Linux¶
Introduction¶
These examples show practical ways to use useradd on a Linux terminal. Each example is written so you can adapt it for administration or troubleshooting.
Example 1: Basic Usage¶
sudo useradd student
This is the simplest form of the command and is a good starting point before adding options.
Example 2: Common Admin Task¶
sudo useradd -m -s /bin/bash student
This example reflects a common task on RHEL, Rocky Linux, AlmaLinux, or similar systems.
Example 3: Useful Option¶
sudo useradd -m -G wheel student
This option helps narrow the result, change behavior, or handle a more realistic target.
Example 4: Real-World Scenario¶
sudo passwd student
Use this pattern when the task moves beyond a single basic command.
Example 5: Verification¶
id student
Example output:
uid=1001(student) gid=1001(student) groups=1001(student)
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
sudo useradd -m -G wheel student
sudo passwd student
id student
Related Guides¶
Summary¶
Good useradd usage means choosing the right option, keeping the target clear, and verifying the result with output you can explain.