useradd
create a useruseradd adds an account to the system. It is deliberately minimal: without -m no home directory is made, and the account has no password until passwd sets one.
useradd -m -s /bin/bash name, then passwd name — two steps to a usable account.
At the terminal
Read the session first, then the notes: each numbered line in the output is answered by the note with the same number.
What the numbered lines are telling you
useradd printed nothing — it worked — but the account cannot log in until a password or an SSH key is set.
Name, an x in place of the password, user id, group id, the comment, the home directory and the login shell.
Created by -m and owned by the new user. Mode drwxr-x--- keeps other users out.
Switches
A switch changes how the command behaves. These are the ones used day to day; man useradd lists the rest. Single-letter switches can usually be joined, so -l -a may be written -la.
-m- Create the home directory.
-s SHELL- Set the login shell.
-G GROUPS- Supplementary groups, comma-separated.
-c COMMENT- A description, usually the full name.
-d DIR- Use this as the home directory.
-r- Create a system account, with a low id.
-u UID- Use this user id.
-e DATE- Set the date the account expires.
Variations worth knowing
The same tool, pointed at a narrower question. These four cover most of what it is reached for day to day.
sudo useradd -m -G sudo -s /bin/bash ashaCreates an administrator who can use sudo.
sudo useradd -r -s /usr/sbin/nologin appsvcCreates a system account for a service: low id, no login.
sudo adduser ashaOn Debian and Ubuntu, a friendlier tool that asks questions and does every step.
useradd -DShows the defaults used when no switch is given.
In cybersecurity
Every account is another way in, so create them on purpose and keep count.
Shared accounts make it impossible to say who did what, and cannot be taken away from one person without affecting the rest.
An account that exists only to run a program should have /usr/sbin/nologin as its shell, so nobody can log in as it.
An account nobody remembers creating — especially one in the sudo group — is a classic sign of a break-in. Review /etc/passwd regularly.