Problem Statement
Which command is used to add a new user in Linux?
Explanation
The useradd command creates a new user account with specified parameters. Basic syntax: useradd username creates a user with default settings. Common options include -m to create home directory, -s to specify shell (e.g., /bin/bash), -G to add to supplementary groups, -c for comment (full name), and -d to specify custom home directory.
Example: useradd -m -s /bin/bash -G sudo,docker -c 'John Doe' johndoe creates user johndoe with home directory, bash shell, adds to sudo and docker groups, and sets full name. After creation, set password with passwd johndoe. The user account is stored in /etc/passwd with encrypted password in /etc/shadow.
Note that adduser (on Debian/Ubuntu) is a more user-friendly wrapper script around useradd that interactively prompts for information and sets up the home directory automatically. Useradd is the lower-level command available on all Linux distributions. Understanding useradd is essential for user management in production servers and automation scripts.
