Modify a user account
high risk
id <user>Record current groups firstusermod -aG <group> <user>Always use -a with -GEdits account attributes: groups, shell, home, login name, lock state.
| Flag | Meaning |
|---|---|
-aG | Append to groups (always use -a with -G)⚠ Without -a the user is REMOVED from all other groups. |
-L | Lock account |
-U | Unlock account |
-s | Login shell |
-d | Home directory (use -m to move) |
-l | Change login name |
usermod -aG docker aliceAdd alice to a group · explain & risk-check →usermod -L aliceLock alice · explain & risk-check →Reference text is hand-written and may be incomplete — check man usermod for your version. Test destructive commands on a non-production system first.