Create a user with the right shell, groups, and home directory, or modify an existing one. The flags differ in ways that matter, and this gets them right.
The single most common way to break an account: usermod -G docker alice sets alice to exactly the docker group and silently removes her from sudo, and from everything else she was in. You almost always want -aG, which appends. There is no confirmation and no warning. Also worth knowing that group membership is read at login, so a user added to a group must log out and back in before it takes effect, and a running shell will keep the old set no matter what id reports elsewhere.
This user account builder generates useradd and usermod commands with the flags that matter: -m to create a home directory, -s for the login shell, -aG to append groups without wiping existing membership, --system for service accounts that should never log in, and -e for account expiry. It also outputs the steps that normally follow, including setting a password or installing an SSH key with the correct permissions.
useradd is the low-level utility present on every distribution and behaves identically everywhere, which is why scripts use it. adduser is a friendlier Perl wrapper on Debian and Ubuntu that prompts interactively and applies sensible defaults, and it does not exist on all systems. Learn useradd; use adduser interactively if you have it.
useradd does not create one unless you pass -m. Without it the account exists and logs in with the home directory missing, which produces confusing errors from shells and applications that expect to write there.
It uses --system, which allocates a UID from the low system range and skips the home directory, and it sets the shell to nologin so nobody can obtain an interactive session with it. The point is that a compromised service cannot be logged into and cannot be used as a foothold.
userdel username removes the account and leaves the home directory. userdel -r removes the home directory and mail spool too. Check for files owned by the UID elsewhere on the system first with find / -uid, because those become orphaned and can be silently reassigned if the UID is reused.