When to use usermod
Use usermod to change an existing account's configuration. Group changes and shell changes can affect access and running workflows; preserve existing memberships unless replacing them is the explicit goal.
Syntax
usermod [PARAMETERS] NAMESquare brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.
Common options and arguments
Usage examples
Add user to group
sudo usermod -aG developers demo-userThe account is appended to a supplementary group while retaining its other memberships.
Change shell
sudo usermod -s /bin/bash demo-userThe configured login shell is changed for future logins.
Check groups after change
id demo-userThe account's configured groups are inspected after the change.
Notes and limitations
- The -G key without -a replaces the list of additional groups.
- Group changes usually take effect for the user after a new login.
Common questions and troubleshooting
Why did other supplementary groups disappear?
Setting a group list without append mode replaces it. Restore the intended memberships from a trusted record and use append mode for additions.
Why does the current session still have old groups?
A running session usually retains the groups assigned at login. Reconnect and inspect the active group set after changing membership.
Further help
Options vary by version and distribution. Check the installed documentation with this command: man usermod.