useradd -m Explained¶
Introduction¶
This article explains a common useradd usage that administrators and learners often need to understand clearly.
What This Command Means¶
The command performs this specific task with useradd:
sudo useradd -m student
Breaking Down the Command¶
useraddis the command being run.- The options or arguments decide the behavior.
- The final value is the target, such as a file, process, service, package, host, URL, or directory.
Practical Examples¶
sudo useradd -m student
sudo useradd -m -s /bin/bash student
id student
Example output:
uid=1001(student) gid=1001(student) groups=1001(student)
When to Use It¶
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.
Safer Alternatives¶
Inspect before changing state when possible:
id student
For wider changes, test on a small target before using the command broadly.
Related Guides¶
Summary¶
Understanding useradd -m is about knowing what each part does and checking the final state after running it.