usermod command
Change user accounts: groups, shell, home, lock.
- Users & permissions
- Package passwd / shadow-utils
- 6 options · 6 examples
Syntax
usermod [options] usernameProvided by the passwd / shadow-utils package. Run man usermod for the full manual.
Common options
| Option | What it does |
|---|---|
-aG GROUPS | Add to extra groups (keep the others) |
-G GROUPS | Set the extra groups (removes others) |
-s SHELL | Change the login shell |
-l NEW | Rename the user |
-L / -U | Lock / unlock the password |
-d DIR -m | Move the home directory |
Examples
Add a user to sudo (Ubuntu)
sudo usermod -aG sudo aliceAdd a user to docker
sudo usermod -aG docker $USERChange the shell
sudo usermod -s /bin/zsh aliceLock an account
sudo usermod -L aliceRename a user
sudo usermod -l alicia aliceRemove from a group
sudo gpasswd -d alice docker
No example matches. Check the options table or search the guides.
Tips
- Always use
-aG;-Galone replaces all extra groups. - Group changes apply at the next login (or run
newgrp docker).
usermod guides
- Adding User in Secondary Group using Command in Linux Linux Commands · Updated Apr 2025
- Removing User from Secondary Group in Linux Linux Commands · Updated Apr 2025
