Quiz Entry - updated: 2026.07.14
How do you create, modify, and delete users in Linux?
Create with useradd, change with usermod, remove with userdel, set the password with passwd — and always use usermod -aG (with the -a) when adding someone to a group.
The single biggest gotcha lives in usermod -G: without -a it replaces the user's entire supplementary group list, silently dropping them from every other group (including wheel/sudo). The -a means "append", which is almost always what you want.
User management commands:
| Command | Purpose |
|---|---|
useradd |
Create new user |
usermod |
Modify existing user |
userdel |
Delete user |
passwd |
Set/change password |
Create user:
sudo useradd -m -g groupname username
sudo useradd -u 1221 -g student -s /bin/bash -c "Full Name" username
useradd options:
| Option | Purpose |
|---|---|
-m |
Create home directory |
-g |
Set primary group |
-G |
Set supplementary groups |
-u |
Set specific UID |
-s |
Set login shell |
-c |
Set comment (full name) |
Modify user:
# Add to group (append!)
sudo usermod -aG wheel username
sudo usermod -d /new/home username # Change home directory
sudo usermod -L username # Lock account
sudo usermod -U username # Unlock account
Delete user:
sudo userdel username # Delete user (keep files)
sudo userdel -r username # Delete user AND home directory
Important: Use -a with -G to APPEND groups. Without -a, existing groups are replaced!